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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Filter a report using query string for relative dates

Hi,

 

Is there a way pre-filter dates? I want my data to get filtered by rolling 30 days. 

I want the user to have an option to change the filter if needed and look for broader time period. But by default when the user opens the link he should see only 30 days since those are most relevant. 

 

My report is automatically refreshed everyday.

 

Regards

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

Hi @Anonymous ,

How about to use filter on this visual?

ee4.PNG

 

 

Days = 
VAR x = 
CALCULATE(
    LASTDATE('Table'[Date]),
    ALL('Table'[Date])
)
RETURN
DATEDIFF(
    MAX('Table'[Date]),
    x,
    DAY
)

 

 

Even if your data is updated daily, only the last 30 days will be displayed.

If you want to display longer data, you need to modify the filter.

 

Best regards,
Lionel Chen

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

7 REPLIES 7
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

How about to use filter on this visual?

ee4.PNG

 

 

Days = 
VAR x = 
CALCULATE(
    LASTDATE('Table'[Date]),
    ALL('Table'[Date])
)
RETURN
DATEDIFF(
    MAX('Table'[Date]),
    x,
    DAY
)

 

 

Even if your data is updated daily, only the last 30 days will be displayed.

If you want to display longer data, you need to modify the filter.

 

Best regards,
Lionel Chen

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

Aron_Moore
Solution Specialist
Solution Specialist

Sure. I have a few reports that filter "Current Month" or "Current Quarter".

 

I just build a custom column that checks like

IF('Executive Report'[Fiscal year / Qtr]=YEAR(TODAY())&" - Q"&ROUNDUP(MONTH(TODAY())/3,0),"Yes","No")
 
Then I just save the report with the filter selected to "Yes".
Anonymous
Not applicable

Thanks! Can this filter be removed by the customers later, if they want to expand the date field? 

Yup. The filter visual looks like this:

Slicer.PNG

 

They can just clear the filter and it'll open the report to all month, quaters, etc.

Anonymous
Not applicable

 

I see! But you have made buckets in your time. Mine is a date slicer like below.  I want to provide 30-day dynamic filter.Screen Shot 2020-01-15 at 2.25.26 PM.png

Yes, I made buckets and that's what makes it dynamic.

 

Whenever the report is refreshed the calculated column is recalculated potentially moving the current quarter.

 

You'll need to do something similar and switch from the Date slicer to a 'regular' slicer to handle the dynamism.

Anonymous
Not applicable

But buckets don't serve our business purpose. We need to drill down to the date level in historical data too.

 

If I have both bucket and date filter, the User Experience is really bad.

Since date selector shows different dates and the bucket filter shows something else. 😞 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.