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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Pricey79
Helper V
Helper V

Using two columns in Switch Function

Hello, I was hoping someone could help me please

 

I have a Switch function something like this :


'Mytable'[Stuff] = "ddd" , "Dave" ,
'Mytable'[Stuff] = "sss" , "Sarah" ,
'Mytable'[Stuff] = "kkn" , "Kev" ,
'Mytable'[Stuff] = "mll" , "Mo" ,
'Mytable'[Substuff] = "DIV, "VLAD",
'Mytable'[Substuff] = "DIVsss", "VLAD",
'Mytable'[Substuff] = "DIVmll", "VLAD",

 

I want to be able to say that if a row in substuff contains mll for example and a row in stuff contains mll , then switch to VLAD

 

How would I do that please? At the moment its only taking the argument from the Stuff column

 

Thank you

 

4 REPLIES 4
Alf94
Solution Supplier
Solution Supplier

Hi @Pricey79 ,

 

I think you could use the AND() function. Try someting like the following measure:

 

Measure =
  SWITCH(
    TRUE(),
    AND( Mytable[Stuff] = "mll", Mytable[SubStuff] = "DIVmll" ), "VLAD",
    AND( Mytable[Stuff] = "sss", Mytable[SubStuff] = "DIVsss" ), "VLAD"
  )

 

If I answered your question, please mark my post as a solution.

 

Best,

@Alf94 thank you for taking the time to reply.

Just to check , Can I carry on the rest of the switch with normal conditions? For example, if my table[stuff] equals mll but [substuff] doesnt, then switch mll to something else?

Alf94
Solution Supplier
Solution Supplier

@Pricey79I am not sure what you mean by "switch mll to something else".

 

You can write different types of conditions in your switch statement:

 

Measure =
  SWITCH(
    TRUE(),
    AND( Mytable[Stuff] = "mll", Mytable[SubStuff] = "DIVmll" ), "VLAD 1",
    AND( Mytable[Stuff] = "sss", Mytable[SubStuff] = "DIVsss" ), "VLAD 1",
    Mytable[Stuff] = "mll", "VLAD 2",
    AND( Mytable[Stuff] = "mll", Mytable[SubStuff] <> "mll" ), "VLAD 3",
    OR( Mytable[Stuff] = "ddd", Mytable[Substuff] = "DIVddd" ), "VLAD 4"
  )

where the "<>" symbol means "not equal".

 

Let me know if this answers your question.

@Alf94 thanks for your time again. Let me see if I can explain it better

 

In the data there is a column called Name and its entires look something like this:

 

AAA - MLL- Answer

AAA- MLL - Correct

AAA- SSS- Answer

 

I have this split this colummn by delimiter using the - and just left the column as the middle characters (MLL, SSS etc) 

This is now called stuff. The switch then says if stuff is MLL then called it Mo , if SSS then Sarah.

The other column called Substuff has the original data in so :

AAA - MLL- Answer

AAA- MLL - Correct

AAA- SSS- Answer

I want to add to the switch that if this column has "Answer" in it, regardless of the MLL or SSS, then call it VLAD

 

Does that help?

 

Thank you

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors