Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
58 | |
56 | |
56 | |
38 | |
29 |
User | Count |
---|---|
75 | |
62 | |
45 | |
40 | |
39 |