How to get selected value from Slicer in Power BI

In this Power BI Tutorial, we will discuss how to get selected value from slicer in Power BI and the below topics with examples:

  • Power BI get selected value from slicer
  • Power BI get selected value from date slicer
  • Power BI get multiple selected value from slicer
  • Power BI get first selected value from slicer
  • Power BI get max selected value from slicer
  • Power BI get selected value from between slicer
  • Power BI get number of selected values from slicer

To execute these above topics, we are going to use this sample excel data. Not only Excel files, but also we can import data from SharePoint list, txt file, My SQL database, CSV file, etc.

If you are new to Power BI, check out how to create a report in Power BI.

Power BI get selected value from slicer

Here, we will see how to visualize a randomly selected value from a slicer on Power BI Report.

For example, here we have created a slicer using only the month’s names from the sample data like this:

Power bi get selected value from slicer
Power bi get selected value from a slicer

Now we will create a measure that will show the selected value from a slicer.

Selected_Month = SELECTEDVALUE('financials'[Date].[Month])

Then we will use this measure on a card chart to visualize the selected value.

Power bi get selected value from slicer
Power bi get selected value from a slicer

This is how to get the selected value from a slicer in Power BI.

Power bi get multiple selected value from slicer

Similarly, we can show multiple selected values from a slicer by using this Power BI measure.

Multi_Selected_Months = CONCATENATEX ( VALUES ( financials[Month Name] ) , [Month Name] , ",")

For example, we will select 2-3 values at a time(Ctrl + select item). Here, we are going to use a card chart to show all the selected values.

Power bi get selected value from slicer
Power bi get selected value from a slicer

This is how to get multi-selected values from a slicer in Power BI.

Read How to create a Measure based on Slicer in Power BI

Power BI get selected value from date slicer

Now we will see how to get a selected value from a slicer using dates in Power BI. Here we are going to create a slicer using the date column from the sample data.

 get selected value from date slicer
get selected value from date slicer

Now we will create a measure, that will show the selected date from the slicer in Power BI.

Date_Selected = CALCULATE(MIN(financials[Date]), ALLSELECTED(financials))
Power BI get selected Date from date slicer
Power BI get selected Date from date slicer

The above screenshot, showing us the selected date that we select from the slicer. If we don’t select any dates from the slicer, then it will show the MIN date from the slicer (i.e. 9/1/2013).

Power bi get selected value from date slicer
Power bi get selected value from date slicer

This is how to get a selected value or date from a date slicer in Power BI.

Power BI get Max selected value from slicer

Now we will see how to get a Max selected date or value from a slicer in Power BI using a Measure.

Here, we will create a measure to show the Max value from the slicer.

Date_Selected = CALCULATE(MAX(financials[Date]), ALLSELECTED(financials))
Power bi get max selected value from slicer
Power bi get max selected value from the slicer

This is how to get a MAX value from the slicer in Power BI.

Power BI get first selected value from slicer

Here we will see how to get the first select value from the slicer in Power BI. For this, we have created a year table having some random years like below:

get first selected value in a slicer
get the first selected value in a slicer

Now we will create a measure that will show the first value from the slicer(i.e. 2002).

First__ Selected__ Year = 
CALCULATE ( 
MIN ( 'Year'[Year] ),
ALLSELECTED () 
) 
 Power BI get first selected value from slicer
Power BI get the first selected value from a slicer

Also, if there is no value get select then we can set a default year as our first selected value.

First__ Selected__ Year = 
IF( 
      ISFILTERED('Year'[Year]),
      CALCULATE ( 
         MIN ( 'Year'[Year] ),
         ALLSELECTED () 
      ),
      YEAR( TODAY() )
   ) 

It will by default showing us the current year as our first selected value.

Power bi get first selected value from slicer
Power bi get first selected value from a slicer

As the current year is 2021, it is showing the current year by default. If we select any value from the slicer, then it will show the value according to our selected value.

Read Power bi slicer contains with examples

Power BI get selected value from between Slicer

Now we will see how to get the selected value from between Slicer using the Switch statement. Here we are going to use our provided sample data based on financial.

Step-1:

First, we will create a table in Power BI. For this, on the Home tab > Enter data.

get selected data using switch
get selected data using switch

Step-2:

Now, we will create two measures for these selections options (i.e. Domestic and International) using profit data from the Sample report.

For Domestic:

Domestic = CALCULATE(SUM('financials'[Profit]),'financials'[Country]= "Canada")

For International:

International = CALCULATE(SUM('financials'[Profit]),'financials'[Country]<>"Canada")

Again, we will create another measure to get the selected value from the slicer.

SlicerSelection = 
VAR Selection =
    SELECTEDVALUE ( 'SelectedValue'[Selections] )
RETURN
    SWITCH (
        TRUE (),
        Selection = "Domestic", [Domestic],

        Selection = "International", [International],
        CALCULATE (SUM('financials'[Profit]))
        )

Instead of using the SELECTEDVALUE formula multiple times, we are using a variable as “Selection” which makes it easier to look at. To get the true value, which in this case will be a calculated value of the selective slicer value, we used the SWITCH(TRUE(),) function.

Step-3:

Now we will use the selections (the table, we have created) in a slicer, and will create an Area chart to show the slicerselections by month.

Power BI get selected value from between Slicer
Power BI get selected value from between Slicer

According to the slicer’s selection, the chart will change its value. Let’s have a look at the below chart.

Power BI get selected value from between Slicer 1

This is how we can get the selected value from between slicer in Power BI.

Power bi get number of selected value from slicer

In Power BI, we can show the total number of a selected value from a slicer easily. For example, here we have created two tables. One table based on country’s name only. Another is based on ID and country’s name.

Table-1:

Get number from slicer
Get number from slicer

Table-2:

Get number from slicer
Get number from a slicer

Now we will create a relationship between two tables from Country name to ID.

Get number from slicer.
Get the number from the slicer

We can show the total count or number of each country by using a card chart. When we will select any value from the slicer, then it will show its total count on the card.

For example, if we will select Canada, then it will show its count as 3 like this:

Power bi get number of selected value from slicer
Power bi get number of selected value from the slicer

This is how to do Power bi get a number of selected value from the slicer.

You may like the following Power BI tutorials:

Conclusion

From this Power BI Tutorial, we discussed these below examples such as:

  • How to get selected value from slicer in power BI?
  • How to get selected value from date slicer in Power BI?
  • How to get multiple selected value from slicer in Power BI?
  • How to get first selected value from slicer in Power BI?
  • How to get max selected value from slicer in Power BI?
  • How to get selected value from between slicer in Power BI?
  • How to get number of selected values from slicer in Power BI?
>