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!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
I have two measures. The first one calculates sales from the year selected in a slicer:
Sales_this_year =
VAR V_year = SELECTEDVALUE(my_table[YEAR])
RETURN
CALCULATE(SUM(my_table[SALES]),
my_table[YEAR] = V_year)
The second one calculates sales from the previous year; the only change to the DAX is subtracting 1 from the year selected in the slicer:
Sales_last_year =
VAR V_year = SELECTEDVALUE(my_table[YEAR])-1
RETURN
CALCULATE(SUM(my_table[SALES]),
my_table[YEAR] = V_year)
The two measures are then displayed on my report in separate cards.
Having two measures that are so similar seems inefficient, especially when scaled up to a full report with many measures like this showing this year's and last year's results.
Is it possible to create a single measure like this, and display it in both cards with filters on each card to determine the year each should be looking at?
Sales = SUM(my_table[SALES])
I'm also open to different ideas if anyone can think of a better way.
Can you try the following ?
Sales = CALCULATE(SUM(my_table[SALES]), ALL(my_table), FILTER(my_table, my_table[YEAR] = SELECTEDVALUE(my_table[YEAR])))
The measure uses the CALCULATE function to calculate the sum of sales, but it also uses the ALL function to remove any filters that are applied to the table. This means that the measure will calculate the sum of sales for all years, regardless of which year is selected in the slicer.
For example, to create a card that shows sales for this year, you would use the following formula:
Sales This Year = CALCULATE(SUM(my_table[SALES]), ALL(my_table), FILTER(my_table, my_table[YEAR] = SELECTEDVALUE(my_table[YEAR])))
Another approach would be to use a parameter to determine the year to calculate sales for. This would allow you to create a single measure that can be used to calculate sales for any year, without having to change the formula.
To do this, you would first create a parameter for the year. Then, you would use the CALCULATE function with the FILTER function to calculate sales for the selected year.
Sales = CALCULATE(SUM(my_table[SALES]), FILTER(my_table, my_table[YEAR] = SELECTEDVALUE(parameter_year)))
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 50 | |
| 46 | |
| 35 | |
| 15 | |
| 14 |
| User | Count |
|---|---|
| 88 | |
| 76 | |
| 41 | |
| 26 | |
| 26 |