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
power bi power bi

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]&"")

power bi

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”
    power bi
  • To display with the full name, use FORMAT for instance:
    IF('table'[argument]=MAX('table'[argument]),"value",FORMAT('table'[argument],"DD MMMM YYYY"))
power bi

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.

power bi

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))

power bi

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”

power bi

This is the result:

power bi

I will explain how to do with the year. The formula will be:

IF('table'[argument]=MAX('table'[argument]),"value",FORMAT('table'[argument],"YYYY"))

power bi

To have it on the top for the filter:

IF('table'[argument]=MAX('table'[argument]),"0",FORMAT('table'[argument],"YYYY"))

power bi

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"))

power bi

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.

power bi

Interesting Topics