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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Date Slicer Between - Default to specific date

Hi! 

I have a report that uses a dates slicer (between) to filter the visuals. 

 

My users wanted to open the report everyday and have the slicer set to a default time range with the max dat set to yesterday (cause every morning they're basically seeing the results from the last day)

 

When trying to achieve this I made a column in my Calendar Table called Day (Relative) that takes value '0' if it's TODAY(). I then filter my Date Slicer visual to have that Day (Relative) be less than 1.

 

My problem now comes when I want to see every day the default date in the slicer and at the same time see my card filtered for that default max date (yesterday).

 

This only works if I click on the slicer circle or manually pick the date again, otherwise, even tho the slicer itself updates cause my report dataset has a daily refresh, the card visual stays blank unlesss I click again on the date slicer.

 

I have attached a sample of my report with this situation. 

 

https://we.tl/t-MhrNbVWzxG 

 

All help welcomed, thank you! 

 

 

5 REPLIES 5
Lyvili
Frequent Visitor

I have the same customer's requirement, any solution to prefiltered as default yesterday date and to have also the posibility also to select a range? 

 

Thanks!

123abc
Community Champion
Community Champion

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:

  1. 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.

  2. 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.
  3. 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().
  4. 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.

Gutierrez
Frequent Visitor

Hello, any solutions on this? without limiting calendar to yesterday?

amitchandak
Super User
Super User

@Anonymous , As of now I doubt you can default the date range slicer.

 

We do a workaround for normal slicer to have column  like

 

Date Type = SWITCH(TRUE(),'Date'[Date]=TODAY(),"Today",'Date'[Date]=TODAY()-1,"Yesterday",'Date'[Date]&"")

 

and save it for yesterday

 

Default Date Today/ This Month / This Year: https://www.youtube.com/watch?v=hfn05preQYA

Anonymous
Not applicable

hii, yes i have considered that solution but it works only if i use a slicer as a dropdown or list, because i'm mixing Text ("Yesterday" and "Today") with my date values. If i use the slicer style "Between" that will not work unfortunately. 

 

meawnhile i have found a work around which was to limit my calendar to end in "yesterday", this way my card visual will not be blank.

 

problem is now if i have other pages in the report that, for example, have forecast and need the calendar to end in something like 31-12-2023 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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