Today I had a requirement from a client to Default the Date Slicer to Today.
I explored different options as to how I can do it -- Like using the Filter Pane -- but this will filter the entire visual or page. So this was not an option.
So I thought of creating a new column named Actual Date in my Date table. So I created as below.
The formula I used was an IF statement,
Actual Date = IF('Date'[Date]=TODAY(),"Today",'Date'[Date])
But this resulted in an error. When you closely look at the formula I have written, you may notice that the output is in two data types.. One is a Text data type which is Today and the other one is a Date which is a Date data type.
So I have now modified the formula as below to convert the date data type into a text data type. Then the error is gone.
Actual Date = IF('Date'[Date]=TODAY(),"Today",'Date'[Date]&"")
Basically what the If statement is doing is -- If the Date is equal to Today's date then the text Today is going to be populated in the Actual Date column, otherwise the date is going to be populated as shown below.
Once you create the new column, create a slicer with the new column (Actual Date) and sort the data by descending and choose Today to default the slicer value.
After this is done, you will notice that the slicer is always defaulted to Today.
You can follow a similar approach for Month as well.
No comments:
Post a Comment