Crash Magic Online
  Intersection Magic
  Map Magic
  Knowledge Base
  Contact Us


Knowledge Base Article:IMW167 

Registration keys moved to client area: Select login on the left menu bar.

Search home page  

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

Article created: Oct 28 2005, updated: Oct 28 2005

Background:  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.

Status:  Info - "how to" article
Keywords:  filter,or,true,false,value
Categories:   *Filters / queries*


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.

October 23, 2019 4:00AM

© 1999-2019 Pd' Programming, Inc - Lafayette, CO USA