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

Get last 3 months with DAX

Hi all,

I want to filter a table by Table[latest_send_date] where this column only contains dates from the last 3 months. In another table I want to apply the same filter but then these months 1 year ago. Anyone have an idea how to do this in DAX? Don't get it done..

Thanks!

1 ACCEPTED SOLUTION
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

1. I 'd like to suggest you use the slicer rather than Dax to achieve this:

007.PNG

2. Alternatively, you can use the DAX formula as below:(Create a calendar table and manage the relationship with your fact table)

value in last 3 months this year = CALCULATE(MAX('Table 4'[Value]),FILTER('Table 4',[Date].[MonthNo]>=MONTH(TODAY())-3&&[Date].[Year]=YEAR(TODAY())))

009.PNG

value in last 3 months last year = CALCULATE(MAX('Table 4'[Value]),FILTER('Table 4',[Date].[MonthNo]>=MONTH(TODAY())-3&&[Date].[Year]=YEAR(TODAY())-1))

008.PNG

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

3 REPLIES 3
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

1. I 'd like to suggest you use the slicer rather than Dax to achieve this:

007.PNG

2. Alternatively, you can use the DAX formula as below:(Create a calendar table and manage the relationship with your fact table)

value in last 3 months this year = CALCULATE(MAX('Table 4'[Value]),FILTER('Table 4',[Date].[MonthNo]>=MONTH(TODAY())-3&&[Date].[Year]=YEAR(TODAY())))

009.PNG

value in last 3 months last year = CALCULATE(MAX('Table 4'[Value]),FILTER('Table 4',[Date].[MonthNo]>=MONTH(TODAY())-3&&[Date].[Year]=YEAR(TODAY())-1))

008.PNG

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

How did you build that slicer with "Last" and designating number of months?  Is that a non-standard slicer?  Thanks

Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

The below article describes how to create a calendar table / date dimension, that will allow you to achieve your requirement.

https://community.powerbi.com/t5/Community-Blog/Relative-Date-Dimension/ba-p/779039

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

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!

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.

Top Solution Authors
Top Kudoed Authors