Create a Field Parameter that lists the target measures and use a single switch measure that selects the appropriate calculation based on the parameter value.
Step‑by‑step implementation
1. Build a disconnected table of measure names
```dax
MeasureList = DATATABLE(
"MeasureName", STRING,
{
{"Sales Amount"},
{"YoY Sales"},
{"Cumulative Sales"},
{"Sales % of Target"}
}
)
```
2. Create the Field Parameter
- In Power BI Desktop, go to Modeling > New parameter > Fields.
- Select MeasureList[MeasureName] as the source column.
- Enable Add slicer to this page.
- The generated table (Parameter_Measure) contains a column Parameter_Measure[Name] and a hidden numeric column used for sorting.
3. Add the parameter slicer to the report canvas; set it to Single select for clarity.
4. Write the master switch measure
```dax
Selected Measure =
VAR _choice = SELECTEDVALUE(Parameter_Measure[Name])
RETURN
SWITCH(
TRUE(),
_choice = "Sales Amount", [Sales Amount],
_choice = "YoY Sales", CALCULATE([Sales Amount], SAMEPERIODLASTYEAR('Date'[Date])),
_choice = "Cumulative Sales", CALCULATE([Sales Amount], FILTER(ALLSELECTED('Date'), 'Date'[Date] <= MAX('Date'[Date]))),
_choice = "Sales % of Target", DIVIDE([Sales Amount], [Sales Target]),
BLANK()
)
```
5. Performance tip – If you have many measures, replace the SWITCH with a calculation group that references the same Parameter_Measure[Name] column; this reduces model size and improves query plans.
Quick comparison
| Approach | Pros | Cons |
|---|---|---|
| Field Parameter + SWITCH | No external tools, works in all service tiers, easy to maintain | Switch statement grows linearly with measures |
| Calculation Group | Single definition, optimal for >10 measures, better storage | Requires Premium capacity (or Power BI Embedded) |
| Separate slicer per measure | Visible explicit options | Clutters UI, duplicate logic |
Use the Field Parameter when you need a lightweight, universally deployable solution; switch to calculation groups as the measure count scales.