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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
wynhodgkiss
Helper III
Helper III

Using SWITCH with multiple conditions, SELECTEDVALUE need an option for all

I'm using SELECTEDVALUE to define 2 variables that I'm using in a switch statement like so:

 

NEW_MEASURE =
var _inditype = SELECTEDVALUE(MeasureTable[IndicatorType])
var _nation = SELECTEDVALUE(Brick_Account[Nation])

RETURN
SWITCH(
    TRUE(),
       _inditype = "Values LC" && _nation = "REPUBLIC OF IRELAND", FORMAT([IRE sales measure],"€0,0"),
    _inditype = "Values LC" && _nation = "UNITED KINGDOM", FORMAT([UK GBP sales measure],"£0,0"),
     _inditype = "Standard Units" && _nation = "REPUBLIC OF IRELAND", FORMAT([IRE SU measure],"0,0"),
   _inditype = "Standard Units" && _nation = "UNITED KINGDOM", FORMAT([UK SU measure],"0,0"),
     _inditype = "Values EUR" && _nation = "REPUBLIC OF IRELAND", FORMAT([IRE sales measure],"€0,0"),
    _inditype = "Values EUR" && _nation = "UNITED KINGDOM", FORMAT([UK EUR ales measure], "€0,0"),
   _inditype = "Values GBP" && _nation = "REPUBLIC OF IRELAND", FORMAT([IRE GBP sales measure],"£0,0"),
   _inditype = "Values GBP" && _nation = "UNITED KINGDOM",   FORMAT([UK GBP sales measure],"£0,0"))
 
Is there a way to either define the variable _nation differently or a new conditon within the SWITCH statement that will allow me to add an "ALL" option when both UNITED KINGDOM & REPUBLIC OF IRELAND are selected or ALL via a slicer?
 
ps; the above measure is used in cards and a table and is only a small sample, there are more conditions. I also have a much simpler measure to use in charts but I have the same requirement for that too
1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @wynhodgkiss 

SELECTEDVALUE will return blank by default if more than one values are selected so assuming that there are only two countries, you can use something like isblank(_nation) = uk + ire

This will return the total value for card and  the total value in a table at the total row only.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
wynhodgkiss
Helper III
Helper III

Perfect, thanks so much

danextian
Super User
Super User

Hi @wynhodgkiss 

SELECTEDVALUE will return blank by default if more than one values are selected so assuming that there are only two countries, you can use something like isblank(_nation) = uk + ire

This will return the total value for card and  the total value in a table at the total row only.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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