Power BI: default selection on filter
This article explains how to set a default selection for a slicer but also, I will tell you how to define it for instance the current or last day or year of a slicer, no matter if new data will be added, the filter will always select the last/current date including if I reset my report. Take note that the same process can be applied for other type of data so I have this simple date table:
Table | Slicer |
![]() |
![]() |
When I create a filter with a single selection, by default, Power BI selects the older date and not the last or current one (01/01/2023). To put it as default, I just have to select the last one and save my report, 01/01/2023 will be selected as default but what happens if a new date will be added (01/01/2024) ? Well it will not be the default one except if I do it manually but the goal is to do it automatically. To do that, I will add a new column with this formula:
IF('table'[argument]=MAX('table'[argument]),"value",'table'[argument]&"")

NOTE:
- Replace table, argument and value by yours. In my picture, I don’t specify the table because the argument is at the same table
- If the argument column is “text”, in my example the “date” column, I will have to change it into “date”
- To display with the full name, use FORMAT for instance:
IF('table'[argument]=MAX('table'[argument]),"value",FORMAT('table'[argument],"DD MMMM YYYY"))

If I create a new filter using this new column and select “current date” as default, no matter if new data will be added, the last date will be always selected by default.

As you can see, the “current date” is down on the list, to have it on the top, I will create another column with this formula:
IF('table'[argument]=MAX('table'[argument]),0,YEAR('table'[argument])*12+ROUNDUP(MONTH('table'[argument]),0))

NOTE: as you can see, all dates have been converted into numbers because this column should be always formatted as “numbers”
Now select “column” then click on “column tools -> sort by column” to select “column 2”

This is the result:

I will explain how to do with the year. The formula will be:
IF('table'[argument]=MAX('table'[argument]),"value",FORMAT('table'[argument],"YYYY"))

To have it on the top for the filter:
IF('table'[argument]=MAX('table'[argument]),"0",FORMAT('table'[argument],"YYYY"))

As for the “column 2”, I will also sort it by column but before that, I will have to change its “data type” from “text” to “whole number”.
If I want the previous year as default, I will use this formula:
IF('table'[argument].[Year]=MAX('table'[argument].[Year])-1,"previous year",FORMAT('table'[argument],"YYYY"))

Again to have it on the top for the slicer:
IF('table'[argument]=MAX('table'[argument]),"0",FORMAT('table'[argument],"YYYY"))
As for the “column 4”, don’t forget to change its “data type” from “text” to “whole number” in order to sort it by column.

Interesting Topics
-
Be successfully certified ITIL 4 Managing Professional
Study, study and study, I couldn’t be successfully certified without studying it, if you are interested...
-
Be successfully certified ITIL 4 Strategic Leader
With my ITIL 4 Managing Professional certification (ITIL MP) in the pocket, it was time to go for the...
-
Hide visual and change background color based on selection
Some small tricks to customize the background colour of a text box...
-
Stacked and clustered column chart or double stacked column chart
In excel, I use a lot the combination of clustered and stacked chart...
-
Refresh Power BI
From the Power BI Service, I can set refresh but, for instance, there is no option to do it monthly or each time a change is made...
-
Power BI alerts to be sent by email from an excel file based on condition
I will explain how to send a list of emails from an excel file after creating alerts...