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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kulpowerbi
Helper I
Helper I

Default selection in Date Slicer for last 30 days where user can change the from date and to date

Hi,

I am looking for a solution where the default selection for a date in the last 30 days and at the same time slider can be changed by the viewer.

This feature is needed so when we see daily data for suppose 5 years data, the chart should look cleaner but currently, it shows the whole 5 years data and the chart looks clumsy. 

 

4 REPLIES 4
Anonymous
Not applicable

@kulpowerbi 

Click on the slicer and under the filters pane you can customize the date to the times you want. See my picture below for reference.

NewPlsHelp_0-1628534322318.png

 

@Anonymous  This solution wonk work as it will freeze the date range to the selection based on the filter pane. I want it to be flexible for end-user. The only requirement is that when it loads the first time the selection of date should be last 30 days.
@amitchandak @Greg_Deckler  @parry2k  can you help. 

@kulpowerbi Well, if you publish it that way, that will be the default. The other way to potentially do it is to get the MIN and MAX of the slicer and compare that to the MIN and MAX of ALL the table (date). Then, if the mins are equal and the maxs are equal, show the last 30 days.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler This was a little tricky but I am able to achieve it by applying your suggestion. Now I have another requirement where I need to provide custom selection based on bookmark clicked.  My sample PBI file 

 

 

I have used drill down and bookmark to get a chart by year/month/qtr/daily.

Requirment:

When Slider is the default, and Bookmark Year clicked, then sales should be show only for custom year e.g 2015 only.

When Slider is the default, and Bookmark Qtr clicked, then sales should be show only for custom Qtr e.g QTR2 and QTR3 only.

 

I have written below dax, can you help me why it's not working..

M_Sales_dynamic date range for each Bookmark =
var bkmrk_selection = [M_Bookmark_Selection]
var sliderTF = IF([Slider_Min_Max_Date]="1","1","0")
var sales_offset_YR = CALCULATE(Sales[Sales],'Calendar'[Year]=2015)
var sales_offset_QT = CALCULATE(Sales[Sales],'Calendar'[Quarter]="Q2")
var sales_offset_MN = CALCULATE(Sales[Sales],'Calendar'[Month]="May")
var sales_offset_DL = CALCULATE(Sales[Sales],'Calendar'[WeekdayNum]=1)

// return sliderTF
return
IF(AND(bkmrk_selection="1", sliderTF="1"), CALCULATE(Sales[Sales],'Calendar'[Year]=2015),

IF(AND(bkmrk_selection="2",sliderTF="1"), CALCULATE(Sales[Sales],'Calendar'[Quarter]="Q2"),
IF(AND(bkmrk_selection="3",sliderTF="1"), CALCULATE(Sales[Sales],'Calendar'[Month]="May"),
CALCULATE(Sales[Sales],'Calendar'[WeekdayNum]=1))))
File example.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.