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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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.



Microsoft MVP



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.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors