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
Haripinnoju
Frequent Visitor

Need Dax query for the last 3 months complete data and this month data till today

Hi, 

 

I need to filter a table with the yearmonth column. Initially I am taking the year and then drill down to yearmonth, for now I want to show the data for the last 3months ( sep, oct,nov( complete data for this month's)and the present month data till today (dec till today), similarly for the next upcoming months it should do it automatically. When I drill up then I should be able to see other years and their whole data. Is it possible to write a dax query for this. 

  • When I use relative date function it is taking the date for the range between 4months, if I take calendar months in the relative date function it is showing the last 4 months complete data, but Ineed this month data. I am not clear on how to take all months data for the previous year and this year if needed when drilled up. Please help.

 

1 REPLY 1
amitchandak
Super User
Super User

@Haripinnoju ,

 

Last three months

 

Last 3 Month =
var _max = eomonth(if(isfiltered('Date'),MAX( 'Date'[Date]) , today()),-1)
var _min = eomonth(_max,-3)+1 ,
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

This month till today

 

MTD =
var _max = MAXX(allselected('Table'), 'Table'[Sales Date])
var _min = eomonth(_max,-1)+1 ,
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

last 3 month till today

 

MTD + 3 months =
var _max = MAXX(allselected('Table'), 'Table'[Sales Date])
var _min = eomonth(_max,-4)+1 ,
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

refer: https://medium.com/chandakamit/power-bi-when-i-felt-lazy-and-i-needed-too-many-measures-ed8de20d9f79

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.