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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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()
  )

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

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

Fabric certifications survey

Certification feedback opportunity for the community.

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.