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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Calculation groups - calendar issue

Hello

I am using calculation groups to compare a series of current measures to the previous quarter and previous December.

 

For some reason the previous December is not working. The DAX i am using is as follows:

 


VAR
_Date = MAXX ( ALLSELECTED ( Sales ), Sales[QUARTER_END_DATE] )
VAR
_LastDec = DATE ( YEAR ( _Date ) - 1, MONTH ( _Date ), DAY ( _Date) )
VAR
_RESULT = CALCULATE ( SELECTEDMEASURE (), FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] = _LastDec ) )

RETURN

_RESULT

 

Using this DAX the data returned is the same as the original measure, i.e. selectedmeasure (). 

 

Any comments on this DAX or suggestions on different ways to filter by previous December are most welcome. 

 

I use a custom column within a calendar table to create a relative month, as follows:

 

RelativeMonth = [Year] * 12 + 'Calendar'[MonthNumber]
- (MAX([Year]) * 12 + MONTH(MAX('Calendar'[Date])))
 
Which is great for calculating previous quarter or previous month, so if anybody knows of something similar for calculating a specific month, like previous December. 
 
Many thanks in advance for any help
3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

 

You could consider to use date column as a slicer.

Then create a measure like below:

current = calculate([measure],filter(all(calendar),date = selectedvalue(calendar[date])))

previous = calculate([measure],filter(all(calendar),date = edate(selectedvalue(calendar[date]),-12)))

 

Best Regards,

Jay

Anonymous
Not applicable

Thanks for your response. I like EDATE function, which is a good alternative to using the relative month DAX that I use. However, I can't see how your DAX for 'previous' will allow me to produce a data point for the previous December. 

 

The issue I am having is I need to always bring through the previous December figure, regardless of the month I am in. So using 

date = edate(selectedvalue(calendar[date]),-12

 

I don't think will give me a figure for the previous December. Correct me if I am wrong.

 

It's really just this bit of the DAX that I need suggestions on alternatives to creating a date filter. 

 

VAR _LastDec = DATE ( YEAR ( _Date ) - 1, MONTH ( _Date ), DAY ( _Date) ) 

 I think the issue with this is that I am using another date to populate the month and Day variables, which in June will mean the MAX day is 30, rather than 31 needed for December, as the last day of the month. 

@Anonymous , do you need something like

last year last month = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1*month(selectedvalue(calendar[date])),MONTH)))

 

last year last month = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1*month(Today()),MONTH)))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.