Forum Discussion
Latest Week Slicer update
- 1 year ago
Hi Sravanthi_B
Your week range column seems to be sorted correctly so I would use the custom column sort to filter the slicer.
Below is a sample calculated column to determine whether a week ending date is in the last 8 weeks ending dates
Last 8 Weeks = Dates[Week Ending Sunday] IN TOPN ( 8, VALUES ( Dates[Week Ending Sunday] ), Dates[Week Ending Sunday], DESC )Use the calculated column as a visual filter
As to the selection to default to the last week, you can leverage the Group by Columns property to "store a filter by using an alternate value, which represents the key of the entity." Power BI uses this key to store the filter, allowing the corresponding filter value in the visual to change dynamically. For instance, if May-24 is selected in the visual and currently has a key of 0, when June arrives, May will shift to a key of 1, and June will take the key of 0. Consequently, the slicer selection will automatically change to June. This property can be accessed using an external tool called Tabular Editor. Demo and further reference can be found here - https://youtu.be/MrEAZREQuXM
In my example, I used RANKX to create an offset column.
Please refer to the attached pbix
- 1 year ago
Hi Sravanthi_B ,
Thank you for reaching out to Microsoft Fabric Community.
Thank you burakkaragoz danextian for the prompt response.
You can show only the latest 8 weeks in your slicer by ranking weeks using their end date. To make sure it updates as new data comes in, use a dynamic filter based on that ranking. Power BI doesn’t let slicers auto-select a value by default, but with a tool like Tabular Editor, you can mark the latest week to be pre-selected. This way, the slicer stays current and highlights the latest week without manual updates.
Thank you.
Hi Sravanthi_B ,
Your week field is text, so when you use MAX() it's doing alphabetical sorting instead of actual date sorting. That's why it's not picking up the latest week properly.
The issue is "07 Jul - 13 Jul 2025" comes before "14 Jul - 20 Jul 2025" alphabetically, but obviously that's not the newest week.
Quick fix: You need to extract the actual end date from your text and use that for comparison. Try this:
IsLatestWeek =
VAR EndDateFromText = DATEVALUE(RIGHT(SUBSTITUTE([Week Range], " - ", REPT(" ", 50)), 11))
VAR ActualMaxDate = MAXX('Week', DATEVALUE(RIGHT(SUBSTITUTE('Week'[Week Range], " - ", REPT(" ", 50)), 11)))
RETURN IF(EndDateFromText = ActualMaxDate, 1, 0)This pulls out the end date from your text string and compares actual dates instead of text.
Better long-term solution: Add a proper date column to your data that represents the week end date. Then you can do normal date comparisons without all this text parsing nonsense.
Alternative: If you control the data source, format your week ranges like "2025-07-13 to 2025-07-19" so they sort properly as text. But the date extraction approach above should work with your current format.
The main thing is getting away from text comparisons for dates. Text just doesn't work for chronological sorting.
If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
This response was assisted by AI for translation and formatting purposes.