Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi all,
I’m building an intra-day Power BI report and I have a requirement to control the behavior of date filters based on a user selection.
I’ve created a disconnected table DatePeriods with 3 options:
Today
Yesterday
Single Date
Expected behavior:
When the user selects "Today" or "Yesterday", the report should show data for today or yesterday automatically.
When the user selects "Single Date", only then the date slicer (from the main Date table) should become active and allow them to select a custom date.
If any other option is selected, the date slicer should appear disabled or hidden.
I’ve written a measure like below to calculate the selected date:
DatePeriods =UNION(// TodayADDCOLUMNS(FILTER(CALENDAR(MIN('Date'[Date]), MAX('Date'[Date])), [Date] = TODAY()),"Type", "Today","Sort", 1),// YesterdayADDCOLUMNS(FILTER(CALENDAR(MIN('Date'[Date]), MAX('Date'[Date])), [Date] = TODAY() - 1),"Type", "Yesterday","Sort", 2),// Custom Range (Allow users to select this and manually adjust dates)ADDCOLUMNS(CALENDAR(MIN('Date'[Date]), MAX('Date'[Date])),"Type", "Custom","Sort", 3))I want to show or enable the date slicer only when "Single Date" is selected. Is there a recommended way to implement this in Power BI?
Thanks in advance!
Hi @manoj_0911,
Thanks for posting your question in the Microsoft Fabric Forum Community. And also thanks to @Rupak_bi for prompt and helpful response.
To control how the date slicer works based on what the user picks:
create a separate table with three choices: Today, Yesterday, and Single Date. Add a slicer using this table so users can choose one of those options.
Based on what they pick, show data for today, yesterday, or let them pick a specific date. Instead of using the date slicer directly, use a calculation to decide what date to show.
To make the date slicer usable only when "Single Date" is picked:
You can put a shape or message over it to block it when not needed, or Use a setting to hide the slicer completely unless "Single Date" is selected.
Thanks & regards,
Prasanna Kumar
Hi @manoj_0911 ,
Slicer works on column. to make this, create a calculated column in the table having dates, and classify it as today, yesterday and single date. now use that column for first slicer and date column as second.
User | Count |
---|---|
84 | |
79 | |
71 | |
47 | |
42 |
User | Count |
---|---|
109 | |
54 | |
50 | |
40 | |
40 |