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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Msurya99
Frequent Visitor

Dynamic Date Range

I have a custom date range. what I want is If someone select last 30 days, Last Month, This month so i have calculated the start date and enddate Accordingly based on users selection that will be applied to entire page and the custom date slicer as well

Msurya99_0-1735050039587.png

 

1 REPLY 1
rohit1991
Super User
Super User

Could you please try below Steps: 
1. Create Helper table (for the slicer):

DateRange = DATATABLE("Option", STRING,
  {{"Last 30 Days"},{"Last Month"},{"This Month"}})

 

2. Two measures:

StartDate =
SWITCH( SELECTEDVALUE(DateRange[Option]),
  "Last 30 Days", TODAY() - 30,
  "Last Month",  EOMONTH(TODAY(),-2) + 1,
  "This Month",  EOMONTH(TODAY(),-1) + 1)
EndDate =
SWITCH( SELECTEDVALUE(DateRange[Option]),
  "Last 30 Days", TODAY(),
  "Last Month",  EOMONTH(TODAY(),-1),
  "This Month",  TODAY())

 

3. One filter measure:

InRange =
VAR s = [StartDate]
VAR e = [EndDate]
RETURN IF( MAX('Date'[Date]) >= s && MAX('Date'[Date]) <= e, 1, 0 )

 

4. Put DateRange[Option] as a slicer >> add InRange = 1 in the page/visual filter pane.
Now picking an option updates the entire page (and any custom date slicer that’s bound to your Date table).


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors