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
Anonymous
Not applicable

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

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@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])

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@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
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

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.