Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Measure using SWITCH breaking my graph

Hi,

Iam trying to use a dynamic value in a grapth. Value is equal to the following measure :

Selected = SWITCH(ALLSELECTED(ReadmissionPeriods[Readmission Types])," 2 Days",[% 2 Day Readmission], " 7 Days",[% 7 Day Readmission],"28 Days", [% 28 Day Readmission])
 
ReadmissionsPeriods table has only one column (Readmission Types). I got it working butas soon as I add more rows to the ReadmissionsPeriods table, my visuals get broken and I cannot use the measure SELECTED anymore. I get the message saying 


MdxScript(Model) (14, 46) Calculation error in measure 'ReadmissionPeriods'[Selected]: A table of multiple values was supplied where a single value was expected.

 

Why is this happening? Can someone help please?

Thanks

Ilky

  • Anonymous , You can not have more than one value in such case

    Try like

    Selected = SWITCH(selectedvalue(ReadmissionPeriods[Readmission Types])," 2 Days",[% 2 Day Readmission], " 7 Days",[% 7 Day Readmission],"28 Days", [% 28 Day Readmission])

     

2 Replies

  • Anonymous , You can not have more than one value in such case

    Try like

    Selected = SWITCH(selectedvalue(ReadmissionPeriods[Readmission Types])," 2 Days",[% 2 Day Readmission], " 7 Days",[% 7 Day Readmission],"28 Days", [% 28 Day Readmission])

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi amitchandak 

      Thank you so much, it worked. You have been such great help 🙂

      However, this is not the first time I am using switch in a measure and in a similar circumstances, it worked wit h the ALLSELECTED([columnname]). What makes it work sometimes and not work the others?

      Regards

      Ilky