Forum Discussion
Dynamic Date Slicer - Default to Latest Available Date with Data
Power BI Date Slicer - Automatically Select Latest Date with Available Data (Composite Key Error & Incorrect Default Selection)
Hi everyone,
I'm trying to configure a native Power BI date slicer so that it automatically defaults to the latest available date with data after every dataset refresh.
For example:
Today's date: 28-Jul-2026
Latest data available in SQL: 27-Jul-2026
The slicer should automatically select 27-Jul-2026 whenever the report is opened or refreshed, because the views will be sent for automation.
Environment
Power BI Desktop Version: 2.155.756.0
Storage Mode: Import
Data Source: SQL Server (AWS RDS)
Tabular Editor 2
Calendar table is a DAX calculated table.
Latest Available Date
I first created a SQL query which always returns the latest available date from all tables containing report data.
LatestAvailableDate =
Sql.Database(ServerName, DatabaseName,
[
Query="
SELECT MAX(LatestDate) AS LatestAvailableDate
FROM
(
SELECT MAX(CreatedDate) AS LatestDate FROM powerbi.BetDetails
UNION ALL
SELECT MAX(CreatedDate) FROM powerbi.DepositWithdrawDetails
UNION ALL
SELECT MAX(CreatedDate) FROM powerbi.PlayerDimension
UNION ALL
SELECT MAX(RegistrationDate) FROM powerbi.PlayerDimension
) t
"])
This returns a single row such as:
LatestAvailableDate
-------------------
2026-07-27 18:35:00
First Attempt
Calendar table:
Calendar =
ADDCOLUMNS(
CALENDAR(TODAY()-450, TODAY()),
"Year", YEAR([Date]),
"Month", FORMAT([Date], "MMM"),
"Month No", MONTH([Date]),
"YearMonth", FORMAT([Date], "YYYY-MM"),
"Month Year", FORMAT([Date], "MMM YYYY"),
"YearMonthSort", YEAR([Date]) * 100 + MONTH([Date])
)
Created:
Slicer Display Date =
FORMAT('Calendar'[Date], "dd MMM yyyy")
Created:
Slicer Key =
VAR LatestDate =
DATEVALUE(MAX('LatestAvailableDate'[LatestAvailableDate]))
RETURN
IF(
'Calendar'[Date] = LatestDate,
"__LATEST__",
FORMAT('Calendar'[Date], "yyyymmdd")
)
Then in Tabular Editor 2 I configured:
Calendar[Slicer Display Date]
→
Group By Columns
→
Calendar[Slicer Key]
After doing this I received the following error:
Column [Slicer Display Date] is part of composite key, but not all columns of the composite key are included in the expression or its dependent expression.I tried removing the Group By property, recreating the columns, and applying Group By only at the end, but the same error always returned.
Second Attempt
I modified the Calendar table so that Slicer Display Date was created inside the Calendar table itself.
I also recreated Slicer Key several times using different DAX expressions including:
VAR LatestDate =
DATEVALUE(
MAXX(
ALL('LatestAvailableDate'),
'LatestAvailableDate'[LatestAvailableDate]
)
)
and other variations using CALCULATE() and MAX().
The composite key error still appeared every time after assigning Group By Columns.
Third Attempt
I then removed the standalone calculated column completely and generated both columns inside the Calendar table itself.
Calendar =
VAR LatestDate =
DATEVALUE(
MAXX(
ALL('LatestAvailableDate'),
'LatestAvailableDate'[LatestAvailableDate]
)
)
RETURN
ADDCOLUMNS(
CALENDAR(TODAY()-450,TODAY()),
"Year",YEAR([Date]),
"Month",FORMAT([Date],"MMM"),
"Month No",MONTH([Date]),
"YearMonth",FORMAT([Date],"YYYY-MM"),
"Month Year",FORMAT([Date],"MMM YYYY"),
"YearMonthSort",YEAR([Date])*100+MONTH([Date]),
"Slicer Display Date",
FORMAT([Date],"dd MMM yyyy"),
"Slicer Key",
IF(
[Date]=LatestDate,
"LATEST",
FORMAT([Date],"yyyymmdd")
)
)
Then again in Tabular Editor:
Slicer Display Date
→
Group By Columns
→
Slicer Key
This time no composite key error occurred.
The Remaining Problem
Unfortunately, the required behavior still doesn't work.
Test 1
- Latest available date in SQL = 27-Jul-2026
- I manually selected 24-Jul-2026
- Saved the PBIX
- Closed Power BI Desktop
- Opened it again
The slicer still showed 24-Jul-2026 instead of automatically changing to 27-Jul-2026.
Test 2
I thought perhaps this only works in the Power BI Service.
So I:
- saved the PBIX with 24-Jul-2026 selected
- published the report
- refreshed the semantic model
Instead of selecting the latest available date, the slicer reset to the first date in the calendar (Sunday, May 04, 2025).
Reference Slicer Not Defaulting to Latest Date in Power BI
The approach I'm trying to implement is from this Microsoft Fabric Community post: Slicer Not Defaulting to Latest Date in Power BI
My Question
Has anyone successfully implemented this solution for a native Power BI date slicer? Would you recommend another solution? The main goal is a setup that is already workingbuilt into Tableau: automatically showing the latest available date containing data instead of the latest day or the latest chosen day in the slicer for future automated report purposes.
If so:
- Is there an additional configuration step that is missing?
- Is this expected to work in both Power BI Desktop and Power BI Service?
- Is there something incorrect in my implementation that causes the slicer to remain on the previously selected date or reset to the earliest date after publishing?
Any guidance would be greatly appreciated.
Thank you!
Hi,
I’m not 100% sure why your setup isn’t working as expected, but I can share a few things I’ve seen work for others in similar situations.
The Group By Columns approach with Tabular Editor is quite tricky and, from what I’ve experienced, it doesn’t always behave the same way in Desktop and Service, which might explain the different results you’re seeing.A simpler alternative that many people use is to create a calculated column in your date table that flags the latest date, like
IsLatest = IF('Date'[Date] = CALCULATE(MAX('FactTable'[Date]), ALL('FactTable')), 1, 0).
and then add that column as a page-level filter set to 1.
This way the report always shows the latest data by default, and you can still use your date slicer for manual selection.
Another option is to switch to a Relative Date slicer set to “in the last 1 day” if that works for your use case. Some people also use bookmarks to save the default state.If you really want the native date slicer to show the actual latest date, the Tabular Editor method you’re trying is the way to go, but it might be worth checking if the “Persistent filters” setting in the Power BI Service is interfering. I hope this gives you a few more paths to try.
Best regards,
DanieleHi! Yes, this is achievable — but it requires a small DAX workaround since Power BI doesn't have a native "default to max date" slicer setting. Just be aware, there is a tradeoff: Because the slicer table is disconnected, your visuals can't be filtered by it directly — they have to be driven by the measure. This means your visuals need to use the Selected Date measure in their filters or calculations rather than relying on the slicer filtering the data model natively. It's a bit more wiring but very manageable.
Here's the cleanest approach:
Rather than using your fact/date table directly in the slicer, you create a disconnected date table with a calculated default, and use a DAX measure to respect the selection while falling back to the max date when nothing is chosen.
Step 1 — Create a disconnected slicer table
This table lists all available dates but is not related to your model. You can generate it with:
SlicerDates = VALUES('DateTable'[Date])
Step 2 — Create a "selected date" measure
Selected Date =
VAR SelectedDates = ALLSELECTED('SlicerDates'[Date])
VAR MaxDate = CALCULATE(MAX('DateTable'[Date]), ALL('DateTable'))
VAR ChosenDate = IF(
ISFILTERED('SlicerDates'[Date]),
SELECTEDVALUE('SlicerDates'[Date], MaxDate),
MaxDate
)
RETURN ChosenDateThis means: if the user has picked something, use it — otherwise default to the most recent date.
Step 3 — Use the slicer table in your slicer
Point your slicer at SlicerDates[Date], set it to dropdown style. On load, nothing is selected, so all your visuals driven by the "Selected Date" measure naturally show the most recent date.
In this screenshot, the tile called Total Sales uses the above method and the table with all teh dates just shows us that the max date is 6/15/20.... the tile called Sales Amount is filtered to that date - and it matches the tile that is dynamic.
If your date table has dates in teh future, reference your fact table instead for the measure:
Total Sales =VAR MaxDate = CALCULATE(MAX('Sales'[OrderDate]), ALL('Sales'))VAR SelectedDate = IF(ISFILTERED('SlicerDates'[Date]),SELECTEDVALUE('SlicerDates'[Date], MaxDate),MaxDate)RETURNCALCULATE([Sales Amount],'Date'[Date] = SelectedDate)
7 Replies
- DanieleUgoCopp
Super User
Hi,
I’m not 100% sure why your setup isn’t working as expected, but I can share a few things I’ve seen work for others in similar situations.
The Group By Columns approach with Tabular Editor is quite tricky and, from what I’ve experienced, it doesn’t always behave the same way in Desktop and Service, which might explain the different results you’re seeing.A simpler alternative that many people use is to create a calculated column in your date table that flags the latest date, like
IsLatest = IF('Date'[Date] = CALCULATE(MAX('FactTable'[Date]), ALL('FactTable')), 1, 0).
and then add that column as a page-level filter set to 1.
This way the report always shows the latest data by default, and you can still use your date slicer for manual selection.
Another option is to switch to a Relative Date slicer set to “in the last 1 day” if that works for your use case. Some people also use bookmarks to save the default state.If you really want the native date slicer to show the actual latest date, the Tabular Editor method you’re trying is the way to go, but it might be worth checking if the “Persistent filters” setting in the Power BI Service is interfering. I hope this gives you a few more paths to try.
Best regards,
Daniele - AnkitKukreja
Super User
Hi! CS02AS
I've setup a workaround for this, I use a column in the SQL with all the dates and use text like "Current Date" for t-1 date like yesterday in your case. Then you can use that in your slicer and publish it on Current Date which will always be latest date as per your built logic. I hope this helps.
- Divyaraj_Rathod
Helper II
The composite-key error and the slicer not landing on the latest date are two separate issues. Group By Columns only controls sort/grouping - it doesn't set a default slicer selection, which is why the slicer kept resetting even after you fixed the error. What you're looking for is the column-level Default Value feature: in Model view, select your Calendar[Date] column, go to the Modeling/Column tools ribbon, and click Default Value. Enter a DAX expression such as CALCULATE(MAX('Calendar'[Date]), 'Calendar'[Date] <= MAX('LatestAvailableDate'[LatestAvailableDate])). This value is recalculated on every refresh and used as the slicer's default, without needing the Slicer Key/composite key workaround at all. It currently works with single-select list/dropdown slicers bound directly to that column, in both Desktop and the Service after publishing.
- audreygerred
Super User
Hi! Yes, this is achievable — but it requires a small DAX workaround since Power BI doesn't have a native "default to max date" slicer setting. Just be aware, there is a tradeoff: Because the slicer table is disconnected, your visuals can't be filtered by it directly — they have to be driven by the measure. This means your visuals need to use the Selected Date measure in their filters or calculations rather than relying on the slicer filtering the data model natively. It's a bit more wiring but very manageable.
Here's the cleanest approach:
Rather than using your fact/date table directly in the slicer, you create a disconnected date table with a calculated default, and use a DAX measure to respect the selection while falling back to the max date when nothing is chosen.
Step 1 — Create a disconnected slicer table
This table lists all available dates but is not related to your model. You can generate it with:
SlicerDates = VALUES('DateTable'[Date])
Step 2 — Create a "selected date" measure
Selected Date =
VAR SelectedDates = ALLSELECTED('SlicerDates'[Date])
VAR MaxDate = CALCULATE(MAX('DateTable'[Date]), ALL('DateTable'))
VAR ChosenDate = IF(
ISFILTERED('SlicerDates'[Date]),
SELECTEDVALUE('SlicerDates'[Date], MaxDate),
MaxDate
)
RETURN ChosenDateThis means: if the user has picked something, use it — otherwise default to the most recent date.
Step 3 — Use the slicer table in your slicer
Point your slicer at SlicerDates[Date], set it to dropdown style. On load, nothing is selected, so all your visuals driven by the "Selected Date" measure naturally show the most recent date.
In this screenshot, the tile called Total Sales uses the above method and the table with all teh dates just shows us that the max date is 6/15/20.... the tile called Sales Amount is filtered to that date - and it matches the tile that is dynamic.
If your date table has dates in teh future, reference your fact table instead for the measure:
Total Sales =VAR MaxDate = CALCULATE(MAX('Sales'[OrderDate]), ALL('Sales'))VAR SelectedDate = IF(ISFILTERED('SlicerDates'[Date]),SELECTEDVALUE('SlicerDates'[Date], MaxDate),MaxDate)RETURNCALCULATE([Sales Amount],'Date'[Date] = SelectedDate) - v-saisrao-msft
Community Support
Hi CS02AS,
Have you had a chance to review the solution shared by DanieleUgoCopp AnkitKukreja Divyaraj_Rathod audreygerred? If the issue persists, feel free to reply so we can help further.
Thank you.
- MattKav
Advocate I
I agree with the other responders here - it's a really simple user feature you're trying to implement, especially as the PBI report will 'remember' the last date you had selected when publishing the report, and thus will always default to that. However it ends up being a really bad user experience, as the date filter increases over time yet users assume they are looking at the most recent!
What I did was a workaround as already mentioned here - I split my report into a 'latest snapshot' page and then a 'historic assessments' page. The 'latest snapshot' uses a field that I create within Power Query called 'latest assessment flag' and then my latest snapshot page has a page filter of TRUE on it. Thus, with each weekly assessment of new data, the page represents just the latest, and there is no confusion for the user.
User feedback was really positive after this improvement....
PS - interestingly I decided not to have that filter on the page a few releases later, instead I applied it to 9 of the 10 visuals on the page, as the 10th visual was a 'historic trend' graph.
- v-saisrao-msft
Community Support
HI CS02AS,
Checking in to see if your issue has been resolved. let us know if you still need any assistance.
Thank you.