The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
My database consists of monthly emissions data from three different years (2020, 2019 and 2018).
I've created three measures to filter the total emissions for each year a forth to compare emissions between 2020 and 2018:
Total 2018 = CALCULATE(Emissions,YEAR('Date'[Date])=2018)
Total 2019 = CALCULATE(Emissions,YEAR('Date'[Date])=2019)
Total 2020 = CALCULATE(Emissions,YEAR('Date'[Date])=2020)
Var 2020-2018= [Total 2020] - [Total 2018].
However, I want to have be able to add a month slicer to my dashboard. That is, I want to be able to compare for instance 2020 and 2018 on Jan + Feb + Mar, or any other months combination that I select. But, when I do so and select the months on this slicer, the result from any of these 4 measures does not change. All I can get is the full year comparison.
Solved! Go to Solution.
The conditions within CALCULATE remove and replace the existing filter context, so slicing on month doesn't change anything since that filter gets replaced.
Try wrapping the conditions with KEEPFILTERS to preserve existing filters.
Total 2018 = CALCULATE ( Emissions, KEEPFILTERS ( YEAR ( 'Date'[Date] ) = 2018 ) )
The conditions within CALCULATE remove and replace the existing filter context, so slicing on month doesn't change anything since that filter gets replaced.
Try wrapping the conditions with KEEPFILTERS to preserve existing filters.
Total 2018 = CALCULATE ( Emissions, KEEPFILTERS ( YEAR ( 'Date'[Date] ) = 2018 ) )
It worked perfectly!
Thank you very much!
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
119 | |
86 | |
75 | |
55 | |
44 |
User | Count |
---|---|
135 | |
125 | |
78 | |
64 | |
63 |