Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hello All Gurus,
I am trying to show Vertical List date slicer which allows single selection and which should dynamically shows todays date as default selection along with all previous dates list. So after daily refresh, default selection changes to the date when it got refreshed and remaining dates shows to select as an option.
I have workarounds however it replaces Today's date with a text like "Today", "Current Date" or whatever text I can input. User wants to see actual date as default selection. But I am not able to write any DAX in new column which is used as Slicer to show actual date even though I have converted it to String format. When any Text can be shown as default selection then why not Date converted into String (By Using Format or Convert function) can be shown as default selection??
It is a very basic user requirement.
Solved! Go to Solution.
Hi again @Nitinmathur
No problem 🙂
It looks like the issue is a circular reference of sorts: if Date Offset is a calculated column that depends on Date Secondary (as in your example), the engine will not allow Date Secondary to have Group By Columns set to Date Offset.
There are many ways circular references can rear their head when defining calculated tables and columns, so I try to keep such definitions in Power Query or further upstream where possible.
A quick fix in your case would be to include Date Secondary in the Dim Calendar calculated table expression.
For example:
Calendar Dim =
ADDCOLUMNS (
CALENDAR ( "03/01/2025", MAX ( Test_Table[Date_Col] ) ),
"Date Secondary", [Date],
"Date Offset", IF ( [Date] = MAX ( Test_Table[Date_Col] ), 0, [Date] )
)
You should then be able to use TMDL View to update Date Secondary by adding:
relatedColumnDetails
groupByColumn: 'Date Offset'
Your particular definition of Date Offset would ensure that selection of the "current date" always remains as a selection of the "current date" after refresh, but selection of any other dates remains as a selection of the displayed date.
Regards
Please suggest what's wrong in these steps
Hi again @Nitinmathur
No problem 🙂
It looks like the issue is a circular reference of sorts: if Date Offset is a calculated column that depends on Date Secondary (as in your example), the engine will not allow Date Secondary to have Group By Columns set to Date Offset.
There are many ways circular references can rear their head when defining calculated tables and columns, so I try to keep such definitions in Power Query or further upstream where possible.
A quick fix in your case would be to include Date Secondary in the Dim Calendar calculated table expression.
For example:
Calendar Dim =
ADDCOLUMNS (
CALENDAR ( "03/01/2025", MAX ( Test_Table[Date_Col] ) ),
"Date Secondary", [Date],
"Date Offset", IF ( [Date] = MAX ( Test_Table[Date_Col] ), 0, [Date] )
)
You should then be able to use TMDL View to update Date Secondary by adding:
relatedColumnDetails
groupByColumn: 'Date Offset'
Your particular definition of Date Offset would ensure that selection of the "current date" always remains as a selection of the "current date" after refresh, but selection of any other dates remains as a selection of the displayed date.
Regards
This worked!
But I am bit curious that we are kind of trying hit and trial and gettin this to work for a very specific slicer type after going thorugh multiple steps. It should have been worked on a first place when we used calculated column of string type with text ("Today" etc) for dynamic value Or Group by property should be made available in pbi , instead of going though TMDL or tabular editor.
For this particular method, the first challenge is that we're using the Group By Columns property which is more-or-less undocumented in relation to Power BI by Microsoft (the SQLBI article is the one I always refer to), and requires an external tool or TMDL to update.
It's certainly not the only feature like this. Calculation group editing used to be similar and editing in Power BI Desktop is relatively new.
In my original reply the blog post I linked to had a PBIX attached but we needed further discussion to adapt that to your model.
Otherwise, it's the perennial challenge of solving these kinds of things via forum 😉
Hello OwenAuge,
Got another use case , user wants to see default date in the Start Date or End Date Filter silcer. when "Between" is used. Example User wants to restrict End Date default to max transaction date from the Fact table or Yesterday date by default in the End Date.
Hi again @Nitinmathur
Unfortunately I don't believe the "group by columns" method works in a way that can be applied to the endpoints of a "between" date slicer 😞
You could restrict the visible dates on the between slicer with a visual-level filter such as
Fact table nonempty = INT ( NOT ISEMPTY ( FactTable ) )
or you could use some sort of calculation group method like in this article but probably simpler:
https://www.sqlbi.com/articles/customizing-default-values-for-each-user-in-power-bi-reports/
Hi @Nitinmathur
This is unfortunately not a built-in feature for the core slicer visuals. However here are a couple of options:
1. Add a "Date Offset" column that is always 0 for the current date (on refresh) and set the Group By Columns property of Date to Date Offset. Power BI translates the filter into a filter on Date offset instead. This works fine with a vertical list slicer (but has some display issues with drop-down slicer).
2. Use the Preselected Slicer custom visual with an appropriate measure.
I believe "default selection" is planned for the core slicer visuals at some stage, or at least has been hinted.
Do either of these methods work for you?
Regards
Thanks Owen, Could you please explain bit more about Option 1? where Can I see "Group By Columns property" of Date and set its value to Date Offset?
@Nitinmathur sure thing 🙂
Assuming you want the slicer to use a Date column from your Date table, here are the steps. After running some tests just now, it turns out that there is a bit more detail to add on top of the blog post linked above (since that concerned a "start of month" column in the Date table).
For now, I'll assume you have a 'Date' table with column 'Date'[Date], which is marked as a date table with 'Date'[Date] specified as the date column.
Steps
1. Add a copy of the Date column to the 'Date' table. I'll assume it's 'Date'[Date Secondary].
This is needed because 'Date'[Date] is normally set as the "key" column of the table (when marked as date table) which conflicts with setting the Group By Columns property.
2. Add a Date Offset column to the 'Date' table. This column can be configured however you like, but should map 1:1 to the Date Secondary column. I'll assume 'Date'[Date Offset] = 0 corresponds to the current date.
3. Use either Tabular Editor 2, Tabular Editor 3, or the TMDL View in Power BI Desktop to set the Group By Columns property of 'Date'[Date Secondary] to 'Date'[Date Offset].
(a) Using Tabular Editor 2:
(b) Using Tabular Editor 3:
(c) Using TMDL View in Power BI Desktop (this is still in Preview)
Before:
column 'Date Secondary'
dataType: dateTime
formatString: dd/mm/yyyy
lineageTag: d837980d-4fa8-4335-989a-b2da7de9b339
summarizeBy: none
sourceColumn: Date Secondary
annotation SummarizationSetBy = Automatic
annotation UnderlyingDateTimeDataType = Date
After:
column 'Date Secondary'
dataType: dateTime
formatString: dd/mm/yyyy
lineageTag: d837980d-4fa8-4335-989a-b2da7de9b339
summarizeBy: none
sourceColumn: Date Secondary
relatedColumnDetails
groupByColumn: 'Date Offset'
annotation SummarizationSetBy = Automatic
annotation UnderlyingDateTimeDataType = Date
4. Now you can create a vertical list slicer in a report using 'Date'[Date Secondary]. If you select the date with Date Offset = 0, then the selection is internally bound to Date Offset rather than Date Secondary. When the model is refreshed and a new date has Date Offset = 0, that date will be selected. Selecting dates corresponding to other Date Offset values will behave in a similar way.
Notes:
I realise that was a bit of detail with the different options.
Let me know how you get on!
Owen 🙂
User | Count |
---|---|
12 | |
12 | |
8 | |
8 | |
6 |
User | Count |
---|---|
27 | |
19 | |
13 | |
11 | |
7 |