cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
armindom Frequent Visitor
Frequent Visitor

IF statement in PowerQuery (M) using values of 2 columns for a row ( Cant use AND)

Hi Everyone,

  I seem to be sleeping.. and strugling with something that should be fairly simple. I need to build a conditional column  that has to take in values dependent on a combination of existing values in 2 other colums

Column A        Column B   Column C
TM                       A              NOTOK
TM                       B               Super
TM                       C               Super
MS                       B                Nice
NB                       C                OK

In powerquery i can build

IF column A = MS then  Nice else if column A = NB then OK [ but i need here a combination of values: 
TM+B or TM+B = Super
TM+A= NOT OK

I can't seem to use "and" with or.. and it is late...maybe a hint will help


2 ACCEPTED SOLUTIONS

Accepted Solutions
edhans New Contributor
New Contributor

Re: IF statement in PowerQuery (M) using values of 2 columns for a row ( Cant use AND)

This will do all but the "NB" logic, but I think you'll get the idea. You most definitely can use "and" but you cannot use the conditional column builder to do it. You'll need to build your formula manually in a custom column.

 

= if [Column A] = "MS" then "Nice" 
     else if [Column A] = "TM" and ([Column B] = "B" or [Column B] = "C") then "Super"
     else if [Column A] = "TM" and [Column B] = "A" then "NOTOK"
     else null
Highlighted
armindom Frequent Visitor
Frequent Visitor

Re: IF statement in PowerQuery (M) using values of 2 columns for a row ( Cant use AND)

Thanks... I will give it a try.. i hope this was just me sleepy Smiley Happy

 

2 REPLIES 2
edhans New Contributor
New Contributor

Re: IF statement in PowerQuery (M) using values of 2 columns for a row ( Cant use AND)

This will do all but the "NB" logic, but I think you'll get the idea. You most definitely can use "and" but you cannot use the conditional column builder to do it. You'll need to build your formula manually in a custom column.

 

= if [Column A] = "MS" then "Nice" 
     else if [Column A] = "TM" and ([Column B] = "B" or [Column B] = "C") then "Super"
     else if [Column A] = "TM" and [Column B] = "A" then "NOTOK"
     else null
Highlighted
armindom Frequent Visitor
Frequent Visitor

Re: IF statement in PowerQuery (M) using values of 2 columns for a row ( Cant use AND)

Thanks... I will give it a try.. i hope this was just me sleepy Smiley Happy

 

Helpful resources

Announcements
Community Highlights

Community Highlights

Find out what's new in the Power BI Community!

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 316 members 3,757 guests
Please welcome our newest community members: