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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Datagulf
Responsive Resident
Responsive Resident

Last 3 Months Filter

I have a Date Table and would like to Filter the Last 3 Months. This means if we are in the Month of December, there should be November, October and September all crumbled together as one item on a filter. How is this possible? Thanks.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Datagulf,

You can create an unconnected date table and use it as source slicer. Then you can write a measure formula to compare selected date and current date if it is including in the three months and use it on your visual to filter records.

Applying a measure filter in Power BI - SQLBI

formula =
VAR currDate =
    MAX ( Table[Date] )
VAR selected =
    MAX ( NewTable[Date] )
RETURN
    IF (
        currDate
            >= DATE ( YEAR ( selected ), MONTH ( selected ) - 3, DAY ( selected ) )
            && currDate <= selected,
        "Y",
        "N"
    )

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Datagulf,

You can create an unconnected date table and use it as source slicer. Then you can write a measure formula to compare selected date and current date if it is including in the three months and use it on your visual to filter records.

Applying a measure filter in Power BI - SQLBI

formula =
VAR currDate =
    MAX ( Table[Date] )
VAR selected =
    MAX ( NewTable[Date] )
RETURN
    IF (
        currDate
            >= DATE ( YEAR ( selected ), MONTH ( selected ) - 3, DAY ( selected ) )
            && currDate <= selected,
        "Y",
        "N"
    )

Regards,

Xiaoxin Sheng

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but one of ways to solve this is using DATESINPERIOD DAX function.

 

DATESINPERIOD – DAX Guide

 

For the StartDate parameter in the function, try using EOMONTH( TODAY(), -1) which gives end date of previous month.

 

I hope this helps.

 

 



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





Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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