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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

Control Range Date by Dropdown filter

Hi all,

 

I have a table calendar with data in each hour.

I created a slicer for date between.

I want to create a dropdown list which calculate today, last 7 days,... and when I choose one value, slicer date between date will reflect. (Or filter all data)

I know it has a slicer call Relative can support this but can I set up this.

Annotation 2020-03-17 171112.png

 

 

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

Hi @Anonymous 

A workaround below:

Create a date table

date = CALENDAR(MIN('Table'[date]),TODAY())

add a column

slicer item =
SWITCH (
    TRUE (),
    [Date]
        = TODAY (), "today",
    DATEDIFF (
        [Date],
        TODAY (),
        DAY
    ) <= 7
        && [Date]
            < TODAY (), "last 7 days",
    DATEDIFF (
        [Date],
        TODAY (),
        DAY
    ) <= 30
        && [Date]
            < TODAY (), "last 30 days"
)

Capture8.JPG

Then edit interactions as below

Capture5.JPGCapture6.JPGCapture7.JPG

 

Best Regards
Maggie
Community Support Team _ Maggie Li
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

5 REPLIES 5
Anonymous
Not applicable

Hello,

i have tried your solution, but I came across an issue. When you use this formula, you will have something like this:

 

10/11/2021 = today

10/10/2021 = yesterday

10/09/2021 = last 7 days

10/08/2021 = last 7 days

10/07/2021 = last 7 days

10/06/2021 = last 7 days

10/05/2021 = last 7 days

10/04/2021 = last 30 days

....

 

and then, when you filter last 7 days, you only get data for 10/09-10/4 instead of 10/11-10/4. Same for last 30 days. Do you get my point?

 

I even tried to build different columns like "last week", "last month", "last year", but then I have problem with hierarchies.  Anyone has solution for that?

 

Thank you.

 

Best Jan

 

v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

A workaround below:

Create a date table

date = CALENDAR(MIN('Table'[date]),TODAY())

add a column

slicer item =
SWITCH (
    TRUE (),
    [Date]
        = TODAY (), "today",
    DATEDIFF (
        [Date],
        TODAY (),
        DAY
    ) <= 7
        && [Date]
            < TODAY (), "last 7 days",
    DATEDIFF (
        [Date],
        TODAY (),
        DAY
    ) <= 30
        && [Date]
            < TODAY (), "last 30 days"
)

Capture8.JPG

Then edit interactions as below

Capture5.JPGCapture6.JPGCapture7.JPG

 

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

 

Thank you.

Anonymous
Not applicable

Hi @v-juanli-msft ,

Thank you so much, That is what I need, I have a concern that Can we remove the blank selection?

It's a little weird for end user when use this.

Once again, I'm very appreciated your support.

amitchandak
Super User
Super User

You can create a slicer like : https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/50...

 

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
Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors