Forum Discussion
Default selection in the dashboard
Hi all,
i have a Quarter field. like bleow 2019Q1,2019Q2,2019Q3,2019Q4 ,2020Q1,2020Q2
So now my requirment is whenever i open the dashboard i want to show latest 4 qurts to be shown in table .later on user will do slice and dice,
it should be dynamic . it should always take latest four quarters only to be selected.
4 Replies
- ibarrau
Super User
Hi. Please consider having a calendar table each time you want to use date in your analysis. First you need a date column (the best option is that the date column is related with the calendar table so you can on calendar table), then you can add a calculated column dax code like this:
Last 4 quarters = IF( DATEDIFF(Calendar[Date], today(), QUARTER) <= 4, "Last 4 quarters", "From last 4 quarter to firt date" )That way you create a column that substract dates with today by quarter. If the result es 4 or less then it's in the last 4 quarters. You can add any text or result you want like the text I'm suggesting.
Once you have this new column just add it as a filter on the page (it can be in the filter pane or in the page). Select the "Last 4 quarters" and boom. Each time the dataset is refreshed it will filter by last 4 quarters from today.
NOTE: if you don't have a date column you can replace "Q1" with "-01-01" to have something from 2019Q1 to 2019-01-01. With that new column the dax should work too.
Hope this helps,
Regards,
- ibarrau
Super User
parry2k I don't think you can. The relative date will only let you work with days, weeks, months and year. However I haven't seen quarters in that analysis. He can try 12 months (4 quartes) because if he doesn't have dates and 2019Q1 = 2019-01-01 then you can use last 12 months but if he has dates like 2019-04-26 that row will need the dax because it won't be filtered with the relative properly.
:S
- v-lili6-msft
Community Support
hi Anonymous
It couldn't achieve that set a default value for a slicer, becasue when you log out of Power BI and come back to a report, the same items will be selected as when you left.
here is the idea, please see detailed explanation in it:
For your case, you could try ibarrau's workaround.
Regards,
Lin