Module 8: Performance, security and sharing · Lesson 8.5 · about 14 min
Field parameters and calculation groups
Let readers pick which measure or dimension a visual shows with field parameters, and avoid writing the same time intelligence for every measure with calculation groups.
Module 8 · about 14 minutes · read first: 6.2. You’ll be able to add measure switching with field parameters and explain calculation groups.
1. Why this matters
Without these, models grow to hundreds of near-duplicate measures (Sales YTD, Units YTD, Margin YTD, Sales LY, Units LY…) and pages fill with near-duplicate charts. Both features are recent favourites in interviews for mid-level roles.
2. Field parameters
Modeling > New parameter > Fields, pick Total Sales, Units and Margin, tick “Add slicer”. Power BI creates a small table and a slicer; put the parameter on a visual’s values, and readers switch measures from the slicer. It also works for dimensions: one chart that can show sales by Store, Category or Region.
The classic DAX pattern behind it (still useful when you need more control) is a disconnected table of choices plus a SWITCH:
A "pick a measure" switch (the classic pattern before field parameters). Split by Product[Category]. The slicer picks Margin; change the starter so "Units" also works.
Press Run to see the result.
Total Sales = SUM(Sales[Amount])
Units = SUM(Sales[Quantity])
Margin = SUMX(Sales, Sales[Amount] - Sales[Quantity] * Sales[UnitCost])
Chosen = VAR Pick = "Margin"
RETURN SWITCH(Pick, "Sales", [Total Sales], "Margin", [Margin], "Units", [Units], BLANK()) In a real model, Pick would be SELECTEDVALUE(Choice[Measure], "Sales") from a slicer on a small table of names.
3. Calculation groups
A calculation group is a special table whose rows (calculation items) are formulas applied to whatever measure is in the visual:
Time Calc[Item] =
"Current" : SELECTEDMEASURE()
"YTD" : CALCULATE(SELECTEDMEASURE(), DATESYTD('Date'[Date]))
"LY" : CALCULATE(SELECTEDMEASURE(), SAMEPERIODLASTYEAR('Date'[Date]))
"YoY %" : VAR Cur = SELECTEDMEASURE()
VAR LY = CALCULATE(SELECTEDMEASURE(), SAMEPERIODLASTYEAR('Date'[Date]))
RETURN DIVIDE(Cur - LY, LY)
Create it in Model view (Calculation group, in recent Power BI versions) or with Tabular Editor. Put the group’s column on a matrix’s columns and any measure on values: you get Current, YTD, LY and YoY % for that measure without writing those measures. Format strings can change per item (YoY % shows as a percentage).
Principle
Principle: separate what is measured (Sales, Units, Margin) from how it’s transformed (YTD, LY, growth). With m measures and t transformations you write m + t definitions instead of m × t.
Try it: 6 base measures and 5 time views. How many measures without calculation groups? (30.) With? (6 measures + 5 items.)
4. Worked example
Northbay’s KPI matrix. Rows: Store. Columns: the Time Calc group (Current, YTD, LY, YoY %). Values: a field parameter that switches between Total Sales, Units and Margin. One visual answers 36 questions, with 3 measures and 4 calculation items behind it.
5. Practice
- Make a field parameter for Store[Store], Product[Category] and Store[Region] and use it on a bar chart’s axis.
- Write a calculation item “MTD”.
- Why can calculation groups confuse report authors?
Answers
- Modeling > New parameter > Fields > choose the three columns > put the parameter on the axis.
CALCULATE(SELECTEDMEASURE(), DATESMTD('Date'[Date])).- They change every measure in the visual, including ones where the item makes no sense (YoY % of a count of stores); good naming and documentation help.
Check yourself
Your ticks stay in this browser. Save them as a file on the course home.
Updated 2026-11-22. Northbay Goods is a made-up shop and its numbers are generated. Power BI changes every month: menu names can move, so check Microsoft Learn if a button is not where the lesson says. The practice editor runs in your browser; nothing you type is sent anywhere.