Two If Not Conditions in Power Query

LtCmdrData

Board Regular
Joined
Jan 24, 2018
Messages
58
Office Version
  1. 365
Platform
  1. Windows
In Power Query I am trying to check two different zip code columns for certain conditions. I want to check each column to see if they contain one of four zip codes. If either column contains any of the four zip codes, then I want one result but if neither column contains any of the four, I want a different result returned. Here is a sample of the M code I tried:

if [Origin Zip] <> "37167" or [Origin Zip] <> "43228" or [Origin Zip] <> "76118" or [Origin Zip] <> "92518"
and [Dest Zip] <> "37167" or [Dest Zip] <> "43228" or [Dest Zip] <> "76118" or [Dest Zip] <> "92518"
then "DS"

else "RS"

Perhaps I need to go about this a different way but I am stuck, probably because of the two negative conditions. Can anyone please help? Thank you in advance.
 
That's why I switched the RS and DS around. If either column matches one of those items, you'll get RS, otherwise you get DS. Is that not what you wanted?
 
Upvote 0
Solution

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I noticed you switched the RS and DS around, but I didn't realize that was intentional. So, I put in the code just the way you have it, and it is working the way I want it to work. Thank you so much for the help and patience.
 
Upvote 0
Glad we could help (@GraH did most of the work to be fair :))
 
Upvote 0

Forum statistics

Threads
1,224,884
Messages
6,181,553
Members
453,053
Latest member
Kiranm13

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top