Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sonuojha1
Helper IV
Helper IV

Slicer to get Multiple selected values

Subject: Slicer to get Multiple selected values and use those values in Variables inside measures

Hi All,

I have a requirement to use slicer's selected multiple values to use to compare different selected measures.

test_slicer.jpg

For example:- user selected two values as above. I want to use these two selected values in a measure to calculate difference between two selected measures.

 

here

1. the first challenge is how to split multiple selected values into two different variables.

2. Then calculate the difference between measure as selected.

 

let say 

Actual This Year is measure and the numeric value is 400

Actual Last Year is measure and numeric value is 200

So if user selected these two values in slicer, then It should call two measures and calculate the difference between Actual This Year - Actual Last Year.

if selected values are as Actual This Year and Forecasted V1 then calculate as difference between Actual This Year and Forecasted V1. and so on..

 

Kindly note, I have done this by applying all combinations between all 4 parameters and worked well. But in that case the calculation is feasible for only 3-4 KPIs comparision. if Number of kpis are more, then it wouldn't be a good solution to create n-1! ( factorial n-1 combinations of comparision).

 

Thanks in advance.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@sonuojha1 , Not very clear try like

 

Measure =
var _min = minx(allselcted('Table'),'Table'[selections])
var _max = maxx(allselcted('Table'),'Table'[selections])
return
Switch( True(),
_max = "ActualThisYear" ,[ActualThisYear],
_max = "ActualLastYear" ,[ActualThisYear]
// Add Other
) - Switch( True(),
_min = "ActualThisYear" ,[ActualThisYear],
_min = "ActualLastYear" ,[ActualThisYear]
// Add Other
)

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@sonuojha1 , Not very clear try like

 

Measure =
var _min = minx(allselcted('Table'),'Table'[selections])
var _max = maxx(allselcted('Table'),'Table'[selections])
return
Switch( True(),
_max = "ActualThisYear" ,[ActualThisYear],
_max = "ActualLastYear" ,[ActualThisYear]
// Add Other
) - Switch( True(),
_min = "ActualThisYear" ,[ActualThisYear],
_min = "ActualLastYear" ,[ActualThisYear]
// Add Other
)

@amitchandak 

Thanks Amit,

 

It worked. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.