Forum Discussion
Custom Date Range Slicer
- 9 months ago
Hi Ugendar,
Thanks for your solution. it working as expected.
Short version: you can’t “re-program” a single Date slicer so that its selectable range changes based on another slicer. Slicers only accept column filters, not measure logic, so they can’t react that way.
You have two practical patterns:
A) Best UX (two slicers + bookmarks)
1. Create a disconnected selector:
Mode =
DATATABLE ( "Mode", STRING, { { "MTD" }, { "Custom" } } )
2. Put two Date slicers on the page:
- Slicer 1 (MTD) → a Relative date slicer set to This month.
- Slicer 2 (Custom) → a normal Between slicer over Date[Date].
3. Use Selection pane + Bookmarks:
- Bookmark MTD: show Slicer 1, hide Slicer 2.
- Bookmark Custom: show Slicer 2, hide Slicer 1.
- Add a Bookmark navigator tied to the two bookmarks, or use the Mode slicer to trigger them.
This gives exactly the behavior you want: user picks MTD → the “This Month” slicer is shown; user picks Custom → a free date-range slicer is shown.
B) Single slicer (limit the effect with a measure)
If you prefer one visible slicer, you can’t restrict its UI, but you can restrict how dates affect visuals when MTD is chosen.
1. Same disconnected Mode table as above.
2. Create a filter measure:
Date Filter :=
VAR ModeSel = SELECTEDVALUE ( Mode[Mode], "Custom" )
VAR D = MAX ( 'Date'[Date] )
VAR StartM = DATE ( YEAR ( TODAY() ), MONTH ( TODAY() ), 1 )
RETURN
IF (
ModeSel = "MTD",
IF ( D >= StartM && D <= TODAY(), 1, 0 ),
1
)
3. Put your normal Between Date slicer on Date[Date].
4. Add Date Filter to the Visual-level filters for all visuals that should respect the rule and set it to is 1.
- When Custom is selected, visuals follow the date slicer normally (all past/future dates allowed).
- When MTD is selected, visuals ignore selections outside the range 1st of current month → today (future and history outside MTD are effectively blocked in visuals).
I hope it helps.
- Koritala10 months agoPost Patron
Hi Ilgar,
Thanks for your email.
Could you please share pbxi file if you already worked on this?
Thanks,
Sri.