Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi Team,
I need your help in achieving the below.
Currently i have a date slicer from which the user can select a particular date or a date range.
How do i make this slicer to default to the max date in the data when user logs in for the first time?
Solved! Go to Solution.
Add Today's date in your model :
let
Source = Date.From(DateTime.LocalNow())
in
Source
Now you may let your date table to generate from start to this date. Now when you put up a filter on the report that defaults to last date in your range which is today's date.
Now coming to your scenario, you will need to play with bookmarks and filters to have it working :
1. Put a filter on your control and set to default range including today's date as you would like and add it to a bookmark.
2. Make this bookmark as your default view in case landing from a link or button .
The user will always default to this view when he logs in.
There is also a possibility that you may give a button"Reset" on your page which can again point to this bookmark with latest date.
I found a solution on youtube. The "trick" is, you must not touch your Slicer. Don't play with it. As soon as you play with it, it saves the setting. If you don't the end will automatically be the latest date.
Set a Dynamic Changing Date in Date Slicer (Power BI) - YouTube
Add Today's date in your model :
let
Source = Date.From(DateTime.LocalNow())
in
Source
Now you may let your date table to generate from start to this date. Now when you put up a filter on the report that defaults to last date in your range which is today's date.
Now coming to your scenario, you will need to play with bookmarks and filters to have it working :
1. Put a filter on your control and set to default range including today's date as you would like and add it to a bookmark.
2. Make this bookmark as your default view in case landing from a link or button .
The user will always default to this view when he logs in.
There is also a possibility that you may give a button"Reset" on your page which can again point to this bookmark with latest date.
@Anonymous , You can create a flag in your date table like this
Is max Date =
var _max = maxx(allselcted(Table), Table[Date])
return
if('Date'[Date]=_max,"MaxDate",[Date]&"")
select MaxDate in your slicer and save. Sort this new column on date column
@amitchandak Thanks Amit. But this will return a text column. How do I get the slicer look for this?
@Anonymous , In the column, I have return rest as dates, you can format if needed and mark date column as sort column so that it can sort on date
Date 1 =[Date] // use this as sort column
Is max Date =
var _max = maxx(allselcted(Table), Table[Date])
return
if('Date'[Date]=_max,"MaxDate",format([Date],"mm/dd/yyyy"))
Refer my video: https://www.youtube.com/watch?v=hfn05preQYA
@amitchandak Thanks Amit again. The dates can be converted to a date format. But i cant have this as a slicer like below to allow an user to select a range of dates.
Currently its gives each individual dates in the list/dropdown like below.
@Anonymous , I doubt you can initialize Range
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
63 |
User | Count |
---|---|
135 | |
126 | |
110 | |
70 | |
61 |