Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
in Power BI by 26 30 35

In my power BI dashboard, I have a date slicer, and I want to pass and use slected slicer value in dax fomula in a measure.

This is the date slicer and I need when selecting a date I can get the selectd value and use it in measure fromula, so basically, How can I use slicer value in a measure in Power BI?

Power BI get selected value from slicer

2 Answers

1 like 0 dislike
by 154 174 350
selected by
Best answer

Use slicer value in a measure in Power BI

To get the slicer selected value and use it in a DAX formula in Measure, you can use one of the below options


Use SELECTEDVALUE() to get the selected slicer value in your DAX formula in a Measure as below

selected value = SELECTEDVALUE('Calendar'[Date])

This would be helpful for the list or dropdown date selection slicer.


Power BI Pass slicer value to a Measure

Min Approach

If you are using between date slicer, you also use the Min approach to pass the selected slicer value in a Measure as below

Slicer Selected Value = Var selectedValue = MIN('Calendar'[Date])
CALCULATE(SUM('Calendar'[Date]),'Calendar'[Date] = selectedValue) 

Or this formula

Slicer Selected Value = CALCULATE(Min('Calendar'[Date]),ALLSELECTED('Calendar')) 

use slicer value in dax formula

Note: The above formula will return the minimum selected value of the slicer in a Power BI Measure where the 'Calendar'[Date] is the column used in the slicer as shown below:

use selected value from slicer power bi


by 26 30 35
0 0
thanks for your help, can you share the pbix file please!
by 26 30 35
0 0
and how can I use the slicer value in calculated column instead the measure in power bi
by 154 174 350
1 0
Sure, I have added the pbix file, and for your new question, please ask it at a new thread!
by 26 30 35
0 0
Thank you for your great help, I will add a new question now and let you know!
0 like 0 dislike
by 12 15 19

Yes, In your case, you can simply use MAX or MIN funtion, so it will take the selected value. Also you can use SELECTEDVALUE.

Yet, in general to be able to have different measures based on the slicer, you need to nest them in switch.

You can create a parameter table hosting the options with datatable, no need for relationship with other tables.
Have your measures ready for each option and then use SWITCH and SELECTEDVALUE together and nest your measures inside.

This video explains it in two ways thoroughly

If you don’t ask, the answer is always NO!