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

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
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,223,929
Messages
6,175,457
Members
452,643
Latest member
gjcase

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