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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
suchomelb
Helper I
Helper I

Trying to figure out how to do an IF/OR case for three columns

I was able to do this easily with two columns, but now I have three separate sources that I want to determine the different types of matching across the columns. I want to use the results as a slicer essentially so I can filter in my report. 

 

Here is an example set of what i'm trying to accomplish:

 

suchomelb_0-1684251664112.png

Basically depending on the criteria it meets if its in one or more columns I want to give it a description like in my Preferred Output example above.

 

Thanks ahead of time for any and all help! 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@suchomelb Try:

Column = 
  SWITCH( TRUE(),
    [A] <> BLANK() && [B] <> BLANK() && [C] <> BLANK(), "In All",
    [B] = BLANK() && [C] = BLANK(), "Not in B or C",
    [A] = BLANK() && [B] = BLANK(), "Not in A or B",
    [C] = BLANK(), "Not in C",
    [A] = BLANK(), "Not in A",
    BLANK()
  )

Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@suchomelb Try:

Column = 
  SWITCH( TRUE(),
    [A] <> BLANK() && [B] <> BLANK() && [C] <> BLANK(), "In All",
    [B] = BLANK() && [C] = BLANK(), "Not in B or C",
    [A] = BLANK() && [B] = BLANK(), "Not in A or B",
    [C] = BLANK(), "Not in C",
    [A] = BLANK(), "Not in A",
    BLANK()
  )

Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

This worked perfect for me. I'm still trying to wrap my head around how it all works but i'm just glad there's people out there like you that do so I can learn it from somebody. I havn't used Power BI for more than six months or so and the DAX seems way more difficult to learn than excel formulas were.  Thanks again!

Syk
Super User
Super User

You can use a custom column to compare multiple values. It doesn't have a gui to help out but the logic should be pretty simple to follow. Check out this post which has an example using dates.
Solved: Power query If submit date between start date and ... - Microsoft Power BI Community

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.