Calculation Groups
Power BI · Advanced Features
Theory
A calculation group is a special table whose rows, called calculation items, are reusable DAX patterns applied to whichever measure is in the visual. Inside an item, SELECTEDMEASURE() stands for 'the current measure'. An item named YTD with the expression CALCULATE(SELECTEDMEASURE(), DATESYTD('Date'[Date])) turns Total Sales into YTD Sales, Total Qty into YTD Qty, and so on, without writing a separate YTD measure for each.
You put the calculation group column on a matrix's columns or a slicer, and each item modifies the measure. For March 2024 in the sample data, Current shows ₹2,200, YTD shows ₹5,700, PY (same period last year) ₹2,500 and YoY % −12.0%. Calculation groups can be created in Model view in Desktop or with external tools such as Tabular Editor; creating one turns on the model's 'discourage implicit measures' setting, so only explicit measures work with it.
Why we use it
Without calculation groups, ten base measures times five time comparisons means fifty measures to write and maintain. Calculation groups collapse that into ten measures plus five items.
When to use it
Use them when the same transformation (time intelligence, currency conversion, scenarios) applies to many measures. Avoid them for one-off logic; they add an abstraction that can confuse new model authors.
How it works
- Many measures need the same variants
- Create a calculation group in Model view
- Add items using SELECTEDMEASURE()
- Set format strings for ratio items
- Is the group placed on a visual or slicer? Yes: Each item rewrites the measure in context. No: Measures show their normal value.
- Fewer measures, consistent logic
Syntax
Model view → Home → Calculation group (first item opens in the formula bar)
More items: right-click Calculation items → New calculation item
Item expression uses SELECTEDMEASURE()
Other functions: SELECTEDMEASURENAME(), SELECTEDMEASUREFORMATSTRING(), ISSELECTEDMEASURE()
Alternatives: TMDL view, Tabular Editor (external tool)Example
// Calculation group 'Time Calc', column 'Time Calc'
Current = SELECTEDMEASURE()
YTD = CALCULATE(SELECTEDMEASURE(), DATESYTD('Date'[Date]))
PY = CALCULATE(SELECTEDMEASURE(), SAMEPERIODLASTYEAR('Date'[Date]))
YoY % =
VAR Cur = SELECTEDMEASURE()
VAR Prev = CALCULATE(SELECTEDMEASURE(), SAMEPERIODLASTYEAR('Date'[Date]))
RETURN DIVIDE(Cur - Prev, Prev)
// YoY % item: set a format string expression of "0.0%"Key points
- Calculation items apply DAX patterns to any measure
- SELECTEDMEASURE() is a placeholder for the measure in context
- Dynamic format strings keep % and currency formats correct
- Creating one discourages implicit measures in the model
- Great for time intelligence across many measures