Forum Discussion
Date Slicer Between - Default to specific date
It seems like you're using Power BI or a similar data visualization tool to create your report. Your goal is to have a date slicer that defaults to a specific time range with the max date set to yesterday, and you want this default behavior to be applied automatically when users open the report.
The issue you're facing with the card visual not updating automatically when you load the report is likely due to the way the slicer interaction is set up. To achieve the desired behavior, you can follow these steps:
Create a Date Table: Ensure you have a Date table in your data model with a column that contains a continuous date range. This table should have a relationship with your main data table.
Set Default Values for Slicer: In Power BI, you can set default values for slicers by using the "Edit Interactions" feature. Here's how you can do it:
- Select the slicer visual that you want to set defaults for.
- In the "Visualizations" pane, click on the "Format" section (paint roller icon).
- Expand the "Edit interactions" section.
You can now define how other visuals on the report page interact with the slicer. For your case:
- For the card visual, set the interaction to "None" so that it doesn't react to changes in the slicer by default.
- For the date slicer, set it to "Filter" so that it filters other visuals.
Create Measures for Default Values: Create DAX measures that calculate the default values you want for the slicer:
- To set the start date to a specific date, create a measure that returns that specific date.
- To set the end date to yesterday, create a measure that calculates yesterday's date. You can use the TODAY() function and subtract one day using EDATE() or DATEADD().
Set Default Values in Slicer: In the slicer, you can set these measures as the default values:
- For the start date, set the default value to your measure that returns the specific start date.
- For the end date, set the default value to your measure that calculates yesterday's date.
Now, when users open the report, the slicer will automatically default to the desired date range, and it should also filter the card visual accordingly without the need for users to interact with the slicer again.
Remember to ensure that your dataset's refresh schedule is set up to update the data daily so that the default end date (yesterday) is always accurate when users open the report in the morning.
Nope, not the answer. Yes, this is part of the solution but not an entire solution. Doing it this way, once a user selects a custom date with the date range slicer, the slicer will not return to the default date range even when clicking a "default date" button or some other workaround.