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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to use Switch on different columns

Hi,

 

I am a beginner 🙂

I need to nest several switch.

Here is the idea (i am creating a new column) :

- If in column A there is the expression "Smart", then return "Idiot", if there is "Green", the return "Color", else return Column A. Up to here i can manage  SWITCH(Column A;"Smart";"Idiot";"Green";"Color";"Column A")

- But here is the thing, I would like, in the same created column, to test the column B also. 

 

Maybe you have a solution?

1 ACCEPTED SOLUTION

Hi @Anonymous,

Please see the below.

Column = 
SWITCH(
    TRUE,
    YourTable[Column A] = "Smart", "Idiot",
    YourTable[Column B] = "Tiger",  "Animal",
    YourTable[Column B]
)


Regards,
Mariusz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Mariusz
Community Champion
Community Champion

Hi @Anonymous 
 You Can use SWITCH with TRUE as a first argument like below.

 

Column = 
SWITCH(
    TRUE,
    YourTable[Column A] = "x" && YourTable[Column B] = "y", "x AND y",
    YourTable[Column A] = "x" || YourTable[Column B] = "y", "x OR y",
    "otherwise W"
)



Regards,
Mariusz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @Mariusz ,

 

thank you for your answer, but maybe I wasn't clear enough.

In the new column, I need evaluate several expression at once and return different results depending on the value.

So, if in column A there is the value "Smart", then return "Idiot" or if in Column B there is the value "Tiger", then return "Animal". Else, column B.

 

Or maybe I didn't understand your answer 🙂

 

Thank you in advance !

Hi @Anonymous,

Please see the below.

Column = 
SWITCH(
    TRUE,
    YourTable[Column A] = "Smart", "Idiot",
    YourTable[Column B] = "Tiger",  "Animal",
    YourTable[Column B]
)


Regards,
Mariusz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you !!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors