Forum Discussion
Default value for filters
I have a report with a date filter in it. Is it possible to give default values to them (preferably pogrammatically) such that every time the report loads, the report is shown for the default values, yet can be run on different date values when changed in the filter provided?
Programmatic change is preferred since the report should be shown by default for the last two weeks (for ex.).
Any help?
Thanks!
10 Replies
- Greg_DecklerCommunity Champion
You can definitely set the filters for the report for defaults, just adjust the values in the Filters area and save the report. However, if someone updates the filters and saves the report, it will change the default. However, if they change the filter and do not save, you will be fine.
Programmatic is not possible right now I believe, you can put a formula like "TODAY()" in the filter and when you apply it, it changes to today's date, but I do not believe that it persists as a formula right now or that you can put in something like "TODAY()-14" for example.
- konstantinosMemorable Member
mebabTo extend Greg_Deckler suggestion you can add a calculated column in your Date table sort of like this
1. Switch ( TRUE ; AND( DateTable[Date] =< Today();DateTable[Date] > Today() - 15 ) ; " Last 2 Weeks" ; ........etc..
then either you create more periods or leave the date filters..to finish the formula..
After you add this column as filter and select by default the "Last 2 Weeks"..Everytime it refreshes the filter will contains the latest 14 days..
2. or with disconnected slicers...a simplified version of http://www.powerpivotpro.com/2013/06/simplifying-time-calculations-and-the-user-experience-using-disconnected-slicers/
- mebabMicrosoft Employee
Hi, thank you for the replies.
My issue is that, I want the report to be run and ready for the up-to-date data but when the user opens it, the filters should contain a default value of start and end dates specifying last two weeks. But the user gets the privilege to change the date filter to any past date and that way the report gets updated with the new datetime values chosen.
Is there any way to support this?
- celciusFrequent Visitor
If yu have a date table set a calculated column as
Days_From_Today = IF([DateId] <= TODAY(), 0 - DATEDIFF([DateId], TODAY(), DAY),DATEDIFF(TODAY(), [DateId], DAY))
where [DateId] is the date column in your date table. This will allow you to set a filter on Days_From_Today of Between -12 and 0.
You can apply this column to your data if you don't have a date table. - celciusFrequent Visitor
Create a calculated column:
Days_From_Today = IF('Date'[DateId] <= TODAY(), 0 - DATEDIFF([DateId], TODAY(), DAY),DATEDIFF(TODAY(), [DateId], DAY))then use it to set your filter as "between -12 and 0". this will then always be the last two weeks.
- AnonymousNot applicable
Did you ever come up with a resolution for this issue? I too would like my published web report date slicer to default to a date range upon loading, but then still provide users the ability to specify a different range once they're working in the report.
Thanks!
- Shahid12523Community Champion
Relative Date Slicer → set it to Last 2 weeks → every time the report loads, it defaults to that window.
DAX Measure + Filter → create a calculated column like:
IsLast2Weeks = IF([Date] >= TODAY()-14, 1, 0)
Then filter the page/visuals where IsLast2Weeks = 1.For published reports, you can also use Bookmarks → save a default state (like “last 2 weeks”) and set it as the entry view.
Best practice: use the Relative Date Slicer, it’s built for exactly this use case.