Forum Discussion

sonuojha1's avatar
sonuojha1
Helper IV
5 years ago
Solved

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.

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.

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

2 Replies

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