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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
wl2020
Frequent Visitor

Measure to get both selected month of the current year, and the same month from the previous year

I am trying to create a waterfall chart that looks like this, which compares the results of last year and this year 

wl2020_0-1617318794945.png

The datatable in question is a vertical table that with a label, a value, and date column. 

wl2020_1-1617319027131.png

 

It is connected to a date table, and I have a drop down slicer with the dates. When a user choose a date, I want to get the results of the date chose, as well as the same date last year, sort of like this

wl2020_2-1617319216188.png

I have created a DAX formula, 

Wasserfall GJ VJ = VAR MonNum = 1 RETURN CALCULATE(SUM(Wasserfall[Value])/1000, Wasserfall[Monat]=MonNum, ALL(ln_dim_period[Jahr1]), ALL(ln_dim_period[Name]))
Which works, but only if I manually enter a number. If I change the number to something dynamic such as SELECTEDVALUE(Month), it would only pull up the information of the month selected, and not that of the same month from the previous year. Does anyone have any idea how to fix the formula so it responds to the date slicer?
1 ACCEPTED SOLUTION

Thanks for the suggestion: I actually managed to solve it by making a sligh modification to your formula: 

Wasserfall GJ VJ = VAR MonNum = CALCULATE(MAX(ln_dim_period[Monat1]), ALLSELECTED(ln_dim_period)) RETURN CALCULATE(SUM(Wasserfall[Value])/1000, Wasserfall[Monat]=MonNum, ALL(ln_dim_period[Jahr1]), ALL(ln_dim_period[Name]))

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @wl2020 

If it is OK with you, please share your sample pbix file, then I can try to come up with desirable measures for your report.

By only seeing the screenshot of your report, in my opinion, no need to write VAR MonNum=1.

Instead,

VAR  currentmonth = Max (currentmonthnumbercolumn in your date table), then fix some of the measures in other area.

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thanks for the suggestion: I actually managed to solve it by making a sligh modification to your formula: 

Wasserfall GJ VJ = VAR MonNum = CALCULATE(MAX(ln_dim_period[Monat1]), ALLSELECTED(ln_dim_period)) RETURN CALCULATE(SUM(Wasserfall[Value])/1000, Wasserfall[Monat]=MonNum, ALL(ln_dim_period[Jahr1]), ALL(ln_dim_period[Name]))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors