Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I have this simple report below, that shows my TotalSales of the month, and my Sales Growth % comparing to last month.
I need to do two things:
1 - create a Time Grain selector, in order to choose to see the data Monthly, Quarterly or Yearly.
2 - I need my Sales Growth % metric to reflect the choice on this selector.
How can I do that?
Here is the link to my pbix file: https://drive.google.com/file/d/1ilt40d75TqNTt3OLjwvYGhy4b5flmXmH/view?usp=sharing
Solved! Go to Solution.
The switch measure needs to match the names in the field parameter. For example, instead of dsc_mesano, I renamed the field (in the field parameter) to Monthly.
Parâmetro-TimeGrain = {
("Monthly", NAMEOF('dim__calendario'[dsc_mesano]), 0),
("Quarterly", NAMEOF('dim__calendario'[dsc_trimestre]), 1),
("Yearly", NAMEOF('dim__calendario'[num_ano]), 2)
}
The switch measure uses Monthly:
Switch Measure =
SWITCH (
MAX ( 'Parâmetro-TimeGrain'[Parâmetro-TimeGrain] ),
"Monthly", [Sales Growth % Monthly],
"Quarterly", [Sales Growth % Quarterly],
"Yearly", [Sales Growth % Yearly]
)
Proud to be a Super User!
This solution uses a field parameter (create it via the UI and then modify the DAX as needed):
Time_Grain_Parameter = {
("Monthly", NAMEOF('dim__calendario'[dsc_mesano]), 0),
("Quarterly", NAMEOF('dim__calendario'[qtr_year]), 1),
("Yearly", NAMEOF('dim__calendario'[num_ano]), 2)
}
https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters
You can add columns or measures to a field parameter. Since the requirement is to display the data according to the selected time grain, I created a field parameter using date table columns.
I created additional measures using your monthly template:
Sales Growth % Quarterly =
VAR CurrentSales = [TotalSales]
VAR PreviousSales =
CALCULATE(
[TotalSales],
DATEADD(dim__calendario[dt_date], -1, QUARTER) -- Ajuste para o nível de tempo desejado
)
RETURN
IF(NOT ISBLANK(PreviousSales),
DIVIDE(CurrentSales - PreviousSales, PreviousSales, 0),
BLANK()
)Sales Growth % Yearly =
VAR CurrentSales = [TotalSales]
VAR PreviousSales =
CALCULATE(
[TotalSales],
DATEADD(dim__calendario[dt_date], -1, YEAR) -- Ajuste para o nível de tempo desejado
)
RETURN
IF(NOT ISBLANK(PreviousSales),
DIVIDE(CurrentSales - PreviousSales, PreviousSales, 0),
BLANK()
)
To determine which measure to display (per the field parameter slicer), create this measure:
Switch Measure =
SWITCH (
MAX ( Time_Grain_Parameter[Time_Grain_Parameter] ),
"Monthly", [Sales Growth % Monthly],
"Quarterly", [Sales Growth % Quarterly],
"Yearly", [Sales Growth % Yearly]
)
Alternatively, you can create a field parameter using the three measures above but users would need to select both the Time Grain (determines the X-axis column) and the corresponding measure. If your model has more measures than just the sum of sales, consider using a calculation group to avoid creating monthly/quarterly/yearly measures for each base measure.
Use these fields in the column chart:
Proud to be a Super User!
Hello! I did as you suggested: I created the field parameter, and then all the measures, but when i put the Switch Measure in my report, it shows blank. It does not show any data. What did I do wrong?
Here is the link for the updated file.
https://drive.google.com/file/d/15O-0tr_CwYRBhrdJ1TN6G7sANpw-sAAB/view?usp=sharing
The switch measure needs to match the names in the field parameter. For example, instead of dsc_mesano, I renamed the field (in the field parameter) to Monthly.
Parâmetro-TimeGrain = {
("Monthly", NAMEOF('dim__calendario'[dsc_mesano]), 0),
("Quarterly", NAMEOF('dim__calendario'[dsc_trimestre]), 1),
("Yearly", NAMEOF('dim__calendario'[num_ano]), 2)
}
The switch measure uses Monthly:
Switch Measure =
SWITCH (
MAX ( 'Parâmetro-TimeGrain'[Parâmetro-TimeGrain] ),
"Monthly", [Sales Growth % Monthly],
"Quarterly", [Sales Growth % Quarterly],
"Yearly", [Sales Growth % Yearly]
)
Proud to be a Super User!
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 103 | |
| 80 | |
| 62 | |
| 50 | |
| 45 |