Adding Dimensions
A dimension is declared once, in konsol's Dimension doctype, and propagates through every model via Jinja macros. dbt never defines a dimension itself: the dimensions var in dbt_project.yml is generated.
How It Works
1. konsol writes the registry into dbt_project.yml
Publishing a Dimension regenerates the block between # --- BEGIN konsol-managed vars and # --- END konsol-managed vars in dbt_project.yml (konsol.dbt_config.regenerate_vars()), and applies the matching ClickHouse DDL (a dim_* column on the budget input tables and on epm_raw.trial_balance_submissions, konsol#287). The demo site's block:
vars:
dimensions:
- name: dim_business_unit
source_column: dim_business_unit
label: Business Unit
cube_type: string
in_budget: false
- name: dim_cost_center
source_column: dim_cost_center
label: Cost Center
cube_type: string
in_budget: true
- name: dim_department
source_column: dim_department
label: Department
cube_type: string
in_budget: true
A site may declare no dimensions (konsol#230); every macro then renders nothing, and the models still compile (konsolidat#220).
2. The macros read the var
dimension_helpers.sql reads var('dimensions') and generates SQL fragments:
select
data_area_id,
{{ dim_select(trailing=true) }} -- dim_cost_center, dim_department, dim_business_unit,
{{ measure_select() }}
from {{ ref('silver_gl_entries') }}
group by
data_area_id{{ dim_group_by(leading=true) }}
3. Where the values come from
- ERP connectors: the staging adapter maps the ERP's field to the canonical
dim_*column (stg_erpnext__gl_entries:cost_center→dim_cost_center,project→dim_business_unit), andstg_gl_entriesharmonises the raw values through konsol's Dimension Mapping crosswalk (dim_harmonize_select/dim_harmonize_joins). Unmapped values pass through and show up ingold_unmapped_dimension_values. - Trial-balance upload: the submitted file's own dimension columns, read by
bronze_trial_balance_submissions(konsol#255) and carried throughsilver_tb_movementsintosilver_gl_entries.
4. The API filters automatically
The Dataset registry (Dataset Dimension rows) decides which dimensions a =K.EPM() call may filter on; the query builder adds them to the WHERE clause.
Adding a New Dimension
- In konsol, create the Dimension (name
dim_<x>, label,in_budget) and publish it. konsol regenerates the var block and applies the DDL. - If an ERP connector feeds the site, add the source field to its staging adapter (
models/staging/<erp>/stg_<erp>__gl_entries.sql) and, for budgets,stg_<erp>__budget_entries.sql. Note: witherp_sourcesnon-empty, the canonical models'unionedCTE still names the three demo dimensions as literals (see the comment ingold_unmapped_dimension_values.sql); konsolidat#221 is removing ERP staging wholesale rather than widening it. - Add Dimension Mapping rows for the ERP's raw values if they need harmonising.
- Rebuild:
dbt build --full-refresh(the incremental models append positionally; a new column needs a full refresh). - Add the dimension to the Datasets that should expose it.
Dimension Properties
| Property | Required | Description |
|---|---|---|
name | Yes | Column name in the models (convention dim_*) |
source_column | Yes | Column dim_select_from_source() casts from in bronze. For the canonical staging path it equals name |
label | Yes | Display name |
cube_type | Yes | Analytical type (currently string) |
in_budget | Yes | true to include in the budget models (get_budget_dimensions()) |
Which Macros Use Dimensions
| Macro | Where used | Effect |
|---|---|---|
dim_select() | SELECT lists | Adds the dimension columns |
dim_group_by() | GROUP BY | Groups by them |
dim_join_on() | JOIN conditions | Matches them across tables |
dim_coalesce() | FULL OUTER JOIN results | Picks the non-null value |
dim_partition_by() | Window functions | Partitions by them |
dim_empty_strings() | Non-entity consolidation layers | '' for IC, CTA, topside, deal rows |
dim_select_from_source() | Bronze | Casts source_column to name |
dim_harmonize_select(), dim_harmonize_joins() | Canonical staging | Crosswalk through Dimension Mapping |
tb_dimension_long_sql() and friends | Hierarchy roll-ups | Unpivot one row per dimension |
All list macros accept trailing=true / leading=true so the comma appears only when the list is non-empty. See Macro Reference.
Budget Dimensions
get_budget_dimensions() returns the dimensions with in_budget: true. Only those exist on gold_spread_budget, gold_scenario_trial_balance, the variance models and the budget input tables. On the demo: dim_cost_center and dim_department; dim_business_unit is excluded.
Dimensions and the year-end close
The year-end close silver_tb_movements synthesizes moves the year's result into retained earnings as one lump on the blank dimension key (decision of 23 Sep 2026, Deepak Pai, konsol#255). A per-dimension close (Dimension.survives_close on) is not built.