Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
setis
Post Partisan
Post Partisan

Compare volume to constant year

I'm trying to compare our Nr of cases to the volume we had in 2019.

In order to do a day to day and MTD comparison, I need to place the measure in a table like this, using 'Date'[Date] from my Canlendar table in rows. 

YOY.PNG

 

My issue is that using the measure below, the results are correct when I don't have any selection in a Year slicer, but it returns blanks when I select 2022

NrCases_2019 = 
CALCULATE (
    [NrCases], //Obs. This measure is just a COUNTROWS from my cases table
    FILTER (
        ALL ( 'Date'[Calendar Month], 'Date'[Calendar Year] ),
        'Date'[Calendar Year] = "2019"
    )
)

How can I ignore all filters and return the volume from 2019 in this situation?

 

I found this post with a solution from @amitchandak but the need seem to be slightly different  Solved: How can I compare a CONSTANT year (i.e 2019) with ... - Microsoft Power BI Community

 

Thank you in advance

1 ACCEPTED SOLUTION

@setis , Check suggestion from @johnt75 .

 

Please check if this can help


NrCases_2019 =
var _max = maxx(allselected('Date'), 'Date'[Date])
var _year = 2019- Year(_max)
return CALCULATE (
[NrCases], dateadd('Date'[Date], _year, year))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

5 REPLIES 5
setis
Post Partisan
Post Partisan

Thanks @johnt75 , doing this, I get the total nr of cases for 2019 on all rows like this:

 

YOY2.PNG

@setis , Check suggestion from @johnt75 .

 

Please check if this can help


NrCases_2019 =
var _max = maxx(allselected('Date'), 'Date'[Date])
var _year = 2019- Year(_max)
return CALCULATE (
[NrCases], dateadd('Date'[Date], _year, year))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@johnt75 thanks for the suggestion, I couldn't make it work like this. 

@amitchandak this one did it for me. It was a clever and simple way to solve it.
Thanks a lot both of you!

Revert back to the DAX you originally had and then check exactly which filters are being applied both when you have 2022 selected in a slicer and when you don't.

If you open the Performance Analyzer from the View ribbon then you can start recording and refresh visuals. Copy the query from the appropriate visual and paste it into DAX Studio. That should show you exactly which columns are being used as filters and you can then include or exclude them from your 2019 measure as appropriate

johnt75
Super User
Super User

Change the ALL line in your filter to be

ALL('Date'),

There may be filters being applied to other columns than the ones you specified, e.g. a sort column used by [Month].

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.