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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

How to get a dynamic date filter to filter only last 08 days

  • Hi,

I have a report with KPI visual and i need to filter this visual only for last 08 days when the user select a date.When select a date the KPI chart automatically should show last 08 days.Can some one help me to do this? 

 

Mishelle_0-1611217480156.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

If you only want to filter last 8 days, you need a separate date table.

2.png

dynamic Date =
VAR _select =
    CALCULATE ( MAX ( DateTable[Date] ), ALLSELECTED ( DateTable[Date] ) )
VAR _last7days = _select - 8
RETURN
    IF (
        MAX ( 'MainTable'[Date] ) >= _last7days
            && MAX ( 'MainTable'[Date] ) < _select,
        1,
        0
    )

3.png

 

You can check more details from here.

 

 

Best Regards,

Stephen Tao

 

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
Anonymous
Not applicable

Hi @Anonymous ,

 

If you only want to filter last 8 days, you need a separate date table.

2.png

dynamic Date =
VAR _select =
    CALCULATE ( MAX ( DateTable[Date] ), ALLSELECTED ( DateTable[Date] ) )
VAR _last7days = _select - 8
RETURN
    IF (
        MAX ( 'MainTable'[Date] ) >= _last7days
            && MAX ( 'MainTable'[Date] ) < _select,
        1,
        0
    )

3.png

 

You can check more details from here.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@Anonymous , refer if this old solution can work

https://community.powerbi.com/t5/Desktop/Required-custom-date-Slicer-Last-7-days-last-15-days-last-30/m-p/1284966#M561629

 

or

Rolling last 8 days with date table

Rolling 8 day = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],'Date'[Date],-8,Day))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

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
Anonymous
Not applicable

Hi  ,

I created a measure to get last 08 days with the MAX date in the date table.This is the measure,

dynamic Date =
VAR _select =
    CALCULATE ( MAX ( DateTable[Date] )ALLSELECTED ( DateTable[Date] ) )
VAR _last7days = _select - 7
RETURN
    IF ( _select > _last7days10 )

but this shows dates from 1st of january to 22nd of january. i need to get only last 08 days.

And i need to put a filter in the filter pane like this,

Dynamic date= 1

image.png

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors