Skip to main content

Calculation groups

A calculation group lets you define a calculation once and apply it to any measure in the model, instead of authoring a separate measure for every combination. The classic example is time intelligence: a single YTD, QTD and Prior Year set that works against every base measure.

In EasyFabric a calculation group is just a table with TableType: CalculationGroup. It lives in the same model.yaml as your fact and dimension tables, so there is no separate file to manage. It has no source table and no Bronze/Silver/Gold object behind it — it is a tabular-only construct.

When at least one calculation group is present, the generator sets DiscourageImplicitMeasures to true on the model. This is required for calculation groups to work correctly in Power BI and is reported as an informational build message.

Processing and refresh

A calculation group has no source data, so it is not loaded through Bronze/Silver/Gold and has no load notebook — it is never part of the data load. What it does need is a recalc: the engine compiles each item's DAX during a ProcessRecalc, and only then is the group queryable.

The standard tabular refresh (DAG_Tabular) refreshes the data tables (Fact/Dim) and then issues a model-wide calculate refresh whenever the model contains a calculation group, so the group is processed automatically after deployment. A plain data-only refresh of the fact/dim tables is not enough to bring a freshly deployed calculation group online — make sure your refresh orchestration runs a recalc (a calculate refresh, or a full model refresh) after deploying the model. Do not add a calculation group to a per-table data-refresh list: it has no partition data to process.

Calculation group table

NameDescription
Name*Name of the calculation group (and its table)
TableType*Must be CalculationGroup
CalculationItems*List of calculation items, each with a Name and a DAX Expression
PrecedenceApplication order when more than one calculation group exists; higher precedence is applied first
CalculationGroupColumnDisplay name of the calculation group column (default Name)
IsHiddenHides the calculation group in Power BI / Excel. Default false
* Indicates that the field is mandatory and must be used.

Calculation item

NameDescription
Name*Name of the calculation item
Expression*DAX expression for the item, e.g. SELECTEDMEASURE()
FormatStringDefinitionDynamic format string DAX expression applied to measures evaluated under this item
OrdinalOrdering of the item within the group
* Indicates that the field is mandatory and must be used.

Basic example

- Table:
Name: Time Intelligence
TableType: CalculationGroup
CalculationItems:
- Name: Current
Expression: SELECTEDMEASURE()
- Name: YTD
Expression: |
CALCULATE(SELECTEDMEASURE(), DATESYTD('Date'[Date]))
- Name: Prior Year
Expression: |
CALCULATE(SELECTEDMEASURE(), SAMEPERIODLASTYEAR('Date'[Date]))

Each item uses SELECTEDMEASURE() to stand in for whatever base measure the report puts the calculation group against.

CalculationItems

CalculationItems is the list of calculations the group exposes. Every item needs a Name and an Expression; generation fails if either is missing, or if the list is empty.

Precedence

- Table:
Name: Time Intelligence
TableType: CalculationGroup
Precedence: 10
CalculationItems:
- Name: YTD
Expression: |
CALCULATE(SELECTEDMEASURE(), DATESYTD('Date'[Date]))

When a model contains more than one calculation group, Precedence controls the order in which they are applied. Higher precedence is applied first. With a single group it can be omitted.

CalculationGroupColumn

By default the column users see in the field list is called Name. Set CalculationGroupColumn to rename it, for example to Time Calculation.

- Table:
Name: Time Intelligence
TableType: CalculationGroup
CalculationGroupColumn: Time Calculation
CalculationItems:
- Name: Current
Expression: SELECTEDMEASURE()

FormatStringDefinition

A calculation item can override the format string of the measures it is applied to by supplying a DAX format-string expression. This is useful when an item changes the unit of the result, for example a percentage variance.

- Table:
Name: Time Intelligence
TableType: CalculationGroup
CalculationItems:
- Name: YoY %
Expression: |
DIVIDE(
SELECTEDMEASURE() - CALCULATE(SELECTEDMEASURE(), SAMEPERIODLASTYEAR('Date'[Date])),
CALCULATE(SELECTEDMEASURE(), SAMEPERIODLASTYEAR('Date'[Date]))
)
FormatStringDefinition: "\"0.0%\""

Ordinal

Calculation items appear in alphabetical order unless you give them an Ordinal. When any item in the group sets an Ordinal, the calculation group column is sorted by it, so the items show up in the order you intend rather than alphabetically.

- Table:
Name: Time Intelligence
TableType: CalculationGroup
CalculationItems:
- Name: Current
Expression: SELECTEDMEASURE()
Ordinal: 0
- Name: YTD
Expression: |
CALCULATE(SELECTEDMEASURE(), DATESYTD('Date'[Date]))
Ordinal: 1
- Name: Prior Year
Expression: |
CALCULATE(SELECTEDMEASURE(), SAMEPERIODLASTYEAR('Date'[Date]))
Ordinal: 2