How to properly use the “OR” (|) operator in a filter expression

Table of Contents

Improper use of the “OR” operator (|) can result in an undesired data set, no data at all, or all data being returned. This article is to help understand its correct use.


Suppose you’ve created a filter like this to remove pedestrians from your diagram.

(First_Harmful <> Ped_~school) | (First_Harmful <> Pedestrian)

This filter does not filter any crashes from your diagram.


Filter statements will always resolved to true or false. When you use an or( | ) statement in your filter you are asking if condition one or condition two is true for each crash record. A true resolution of either condition will include the crash, and only a false resolution of booth conditions will filter the crash.

Here is an example of how (First_Harmful <> Ped_~school) | (First_Harmful <> Pedestrian) would work.

Crash value

Ped_~School     ((First_Harmful<>Ped_~School)=False  or  (First_Harmful<>Pedestrian)=True)   statement is true 
Pedestrian         ((First_Harmful<>Ped_~School)=True    or  (First_Harmful<>Pedestrian)=False)  statement is true 

Ped_~School and Pedestrian values would not be filtered from the list of crashes.

The correct way to write this filter would be to use an and statement

(First_Harmful <> Ped_~school) & (First_Harmful <> Pedestrian)

Value used
Ped_~School    ((First_Harmful<>Ped_~School)=False and  (First_Harmful<>Pedestrian) =True) statement is False
Pedestrian         ((First_Harmful<>Ped_~School)=True  and  (First_Harmful<>Pedestrian)=False) statement is False 

Ped_~School and Pedestrian values would be filtered from the list of crashes.

Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?