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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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.



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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