Forum Discussion
Simple 'and' vs 'or' question for M code
- Anonymous5 years ago
It might be the <> operator that is tripping you up. In you first example, you say that the Employee ID does not equal "user1" AND ALSO does not equal "user2". So everything but "user1" AND "user2" makes it through the filter (will evaluate to true).
In your second example, as the commenter correctly stated, you are writing that the Employee ID can get through the filter if it's either NOT "user1" OR NOT "user2". Power Query says let me see one of these statements are true:
Is the value not equal to "user1"? Yes? The first part of the or statement is true. Send the value through the filter, we're done.
If the value IS = to "user1", then the <> statement is false, so we go to the next part of "or":Is the value not equal to "user2"? If it is not equal to "user2", the statement is true, send it through the filter.
Think of or as two doors, each with a sign: YOU CAN ENTER HERE IF YOU ARE NOT USER1, and
YOU CAN ENTER HERE IF YOU ARE NOT USER2.
See how there is a door for both users?--Nate
It might be the <> operator that is tripping you up. In you first example, you say that the Employee ID does not equal "user1" AND ALSO does not equal "user2". So everything but "user1" AND "user2" makes it through the filter (will evaluate to true).
In your second example, as the commenter correctly stated, you are writing that the Employee ID can get through the filter if it's either NOT "user1" OR NOT "user2". Power Query says let me see one of these statements are true:
Is the value not equal to "user1"? Yes? The first part of the or statement is true. Send the value through the filter, we're done.
If the value IS = to "user1", then the <> statement is false, so we go to the next part of "or":
Is the value not equal to "user2"? If it is not equal to "user2", the statement is true, send it through the filter.
Think of or as two doors, each with a sign: YOU CAN ENTER HERE IF YOU ARE NOT USER1, and
YOU CAN ENTER HERE IF YOU ARE NOT USER2.
See how there is a door for both users?
--Nate
Ah, of course. The logic went right over my head. Silly mistake.
Thank you for taking the time to explain!