Why won't the "or" formula work here?

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered

Here is my formula: 


If([Related Client]=8 and ([ServiceAddress: Postal Code]<>"70114" or [ServiceAddress: Postal Code]<>"70131"), "Incorrect client for postal code")


Even when the postal code is 70114, it will produce the "incorrect client for postal code" result. If I do a formula without the "or" it works as intended. (i.e.: if([Related Client]=8 and ([ServiceAddress: Postal Code]<>"70114", Incorrect client for postal code")

Photo of Taylor

Taylor

  • 52 Points

Posted 4 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,224 Points 20k badge 2x thumb
If [ServiceAddress: Postal Code]="70114" then the two clauses in your if statement would be:

"70114"<>"70114" => false

"70114"<>"70131" => true

so the OR of the two clauses would be:

"70114"<>"70114" OR "70114"<>"70131"  => false OR true => true

So under these conditions the if statement is equivalent to:
If([Related Client]=8, "Incorrect client for postal code")
Is that what you expected?
I think what you really mean is

If(
[Related Client]=8
and
[ServiceAddress: Postal Code]<>"70114"
and
[ServiceAddress: Postal Code]<>"70131", "Incorrect client for postal code")

Ie you are trying to say that if it's a particular client, then their postal code has to be one of those two choices, else flag an error.
Photo of Taylor

Taylor

  • 52 Points
This makes perfect sense now that you've explained it. Thanks!