Forum Discussion

keyway's avatar
keyway
Frequent Visitor
6 years ago
Solved

Multi selection in a SWITCH(TRUE()

Hi

 

I have the followed measure

 

Selected Item = 
VAR Selection = SELECTEDVALUE(Cost_Item,[Attribute],"All"

RETURN

SWITCH(
TRUE(),

Selection = "Salary", [Salary],

Selection = "Taxes",[Taxes],

Selection = "Commission",[Commision],

BLANK()

)

 

But i want to select more than one attribute and sum them:

I've tried

Selection IN ("Salary","Taxes"), [Taxes]+[Salary]

But that doesnt work

 

Any Help?

 

Thank you

 
 
 
  • Hi keyway ,

     

    Yes something similar to that.

     

    Can you share a small sample of data and how you are calculating the taxes, and other measures?

10 Replies

    • keyway's avatar
      keyway
      Frequent Visitor

      Hi

       

      Yes, in fact that is the syntax i have on the code, i just missplaced the brakets on the message.

      It shows a blank result

       

      Thank you

       

      • SH-4's avatar
        SH-4
        Frequent Visitor

        Was this ever actually resolved? I've tried Selection IN {a, b, c} = a + b + c and it does not work.

        I can only get my switch statement to work with single selection, but I need to be able to factor in for multiple selections and can't seem to find a solution if this is possible.

  • Hi keyway ,

     

    Looking at your expression I'm assuming that you have an attribute column with (Salary, Taxes and Comission) and some measures with Salary, Taxes and Comission correct?

     

    If you just make the Salary + Taxes + Comissions using a slicer should give expected result since the calculation of each measure will only be made if you select the value.

     

    If this is not expected result can you share a sample of you data and expected value please.

     

     

    • keyway's avatar
      keyway
      Frequent Visitor

      Hi Miguel

       

      Your assumptions are correct:

      If i select more than one item using a slicer the result is always a blank value, if i select one single item from the slicer i get the correct value.

    • keyway's avatar
      keyway
      Frequent Visitor

       

      You mean something like this Selection = "Taxes",[Taxes]+0 ?

      • MFelix's avatar
        MFelix
        Super User

        Hi keyway ,

         

        Yes something similar to that.

         

        Can you share a small sample of data and how you are calculating the taxes, and other measures?