Forum Discussion
Date slicer
Hi, I have a date slicer from dim_date table which is connected to the fact_tables. Now, I want the date filter to show todays date, even if there is no data available
4 Replies
- AnonymousNot applicable
Thanks for the reply from Kedar_Pande and 123abc , please allow me to provide some additional insights.
Hi Zulaikha ,
You could create a new date table based on the minimum date in your 'dim_table'.
Date = ADDCOLUMNS( CALENDAR( MIN('Table'[Date]), TODAY() ), "Year", YEAR([Date]), "Month", MONTH([Date]), "Day", DAY([Date]) )It will refresh to the current date and we could use ‘Between’ in the date slicer setting
Don't forget to create a new relationship with the fact_tables.
Could you please provide example data or sample files here if you have any confused? We could offer you more help if we have information in detail. There is sensitive data that can be removed in advance. How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Thanks for your understanding. Your time and cooperation are much valued by us. We are looking forward to hearing from you to assist further.
Best regards,
Lucy Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- 123abcCommunity Champion
You can achieve this in Power BI by using a combination of DAX and setting the default value for your date slicer. Here’s a step-by-step guide:
Create a New Measure:
- Go to your dim_date table and create a new measure to get today’s date.
TodayDate = TODAY()
Add a Calculated Column:
- Add a calculated column in your dim_date table to check if the date is today.
IsToday = IF('dim_date'[Date] = TODAY(), 1, 0)Set Default Value in Slicer:
- Add the IsToday column to your slicer as a filter and set it to 1. This will ensure that today’s date is selected by default.
Adjust Slicer Settings:
- Go to the slicer settings and ensure that it allows for single selection. This way, even if there’s no data for today, the slicer will still show today’s date.
By following these steps, your date slicer should default to today’s date, even if there’s no data available for that date. Let me know if you need any more help!
- ZulaikhaFrequent Visitor
I want the slicer setting to be " Between "
- Kedar_PandeSuper User
Use a measure to set today’s date as the default filter in the slicer.
DefaultDate =
IF(
MAX('dim_date'[Date]) = TODAY(),
1,
0
)Add the DefaultDate measure.
Set the filter to show only rows where DefaultDate = 1.This ensures the slicer highlights today’s date by default but still allows the user to select other dates if needed.
💌 If this helped, a Kudos 👍 or Solution mark ✅ would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn