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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

How to calculate change from previous month -- but only within the same year

I'm looking for the DAX code to write a Power BI measure to calculate the change in value from the previous month. But I don't want January to show the change since December; instead, I want January to show the difference from the budget amount. I'm going to use the measure in a waterfall graph.

 

I used the Quick Measure to generate the code to calculate the change in value:

 

LE Difference = 
     VAR __Prev_Month = CALCULATE([Monthly LE], DATEADD('Date'[Date].[Date], -1, MONTH)) 
RETURN
    [Monthly LE] - __Prev_Month 

 

But since I want the January value to be the change from the Budget (instead of from last December's Latest Estimate), my plan is to test for the Month Number and change the formula accordingly. I tried inserting 

VAR This_month = month('Date'[Date].[Date])

but this gives me the error: A single value for variation 'Date' for column 'Date' in table 'Date' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

 

And I suspected that this would happen, but I don't remember how to work around it.

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , from syntax's perspective, you might want to try,

VAR this_month = MONTH( MAX('Date'[Date].[Date]) )

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , from syntax's perspective, you might want to try,

VAR this_month = MONTH( MAX('Date'[Date].[Date]) )

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Yes, that worked, as did

   This_month = max('Date'[Date].[Month])

 

though I'm not sure why the max month is able to change for each iteration.

CNENFRNL
Community Champion
Community Champion

As a matter of fact, MAX('Date'[Date].[Month]) is a syntactic sugar for MAXX('Date', 'Date'[Date].[Month]); here 'Date' table is subject to changes of filter context. During iteration, filter context changes; MAX() changes accordingly.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (27)