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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
kousar99
Helper I
Helper I

How to create a measure to get date of last 5 days

Hi Experts,

 

I have a requirement where we are using a matrix for showing data and need to build a button(Last 5 days date) and when we click on that it should show only the last 5 days' data in the matrix,

For particular requirements on how to build a measure, Need your input and suggestions

 

Thanks in advance,

 

Regards,

Hk

1 ACCEPTED SOLUTION
MohammadLoran25
Solution Sage
Solution Sage

Hi @kousar99 ,

 

1-You can create a flag column. If gives 1 value (or the text "Last 5 days") to the records that are last 5 days (Today and 4 days before). Then you can put this column as a slicer which contains last 5 days.

 

2-In terms of measure, You can do this:

Last5DaysMEasure =
CALCULATE (
    [YourMeasure],
    FILTER (
        ALL ( 'DateTable' ),
        'DateTable'[Date]
            >= TODAY () - 4
            && 'DateTable'[Date] <= TODAY ()
    )
)

 

If this answer solves your problem, give it a thumbs up and mark it as an accepted solution so the others would find what they need easier.

Regards,
Loran

View solution in original post

1 REPLY 1
MohammadLoran25
Solution Sage
Solution Sage

Hi @kousar99 ,

 

1-You can create a flag column. If gives 1 value (or the text "Last 5 days") to the records that are last 5 days (Today and 4 days before). Then you can put this column as a slicer which contains last 5 days.

 

2-In terms of measure, You can do this:

Last5DaysMEasure =
CALCULATE (
    [YourMeasure],
    FILTER (
        ALL ( 'DateTable' ),
        'DateTable'[Date]
            >= TODAY () - 4
            && 'DateTable'[Date] <= TODAY ()
    )
)

 

If this answer solves your problem, give it a thumbs up and mark it as an accepted solution so the others would find what they need easier.

Regards,
Loran

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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