Examples

Top  Previous  Next

Generic vs User specific examples

The real power of the filter is that it can access any of the fields in the database.  Some users don't know it, but every installation of the program is able to use different field names and lookup values.  Crash Magic tries to keep this transparent to the user.  This section has two types of examples.

Generic filter examples are ones that should work on all configurations of Crash Magic.  These examples use only the base fields.

User specific filter examples are ones that require that certain fields exist in the database in order to work properly.  Note that the program will warn the user if a field or lookup value does not exist.  A filter will not be processed if it is not valid for the given database.

Generic filter examples

Filtering on time of day

The filter can be used to display only crashes occurring during certain times of day.  To do this, the Time field is used.  Time is stored as a number from 0-2400.

Show all crashes that occurred at 8am

1.        Time=800

Show all crashes that occurred between 8 and 9 am

1.        Time >= 800

2.        Time <= 900

another way of obtaining this condition using only one line is:

1.        (Time >= 800 ) & ( Time <= 900 )

Show all crashes which occurred between 7:30am and 8:30am or 4:30pm and 6pm (rush hour)

1.        ((Time >=730 ) & (Time <= 830)) | ((Time >=1630 ) & (Time <= 1800))

note that extra parentheses are used to group the two time periods so that they can be compared using the | (or) operator.

Filtering on Milepost

Show all crashes that occurred between milepost 12 and milepost 15

1.        (mile_1 >= 12 )

2.        (mile_1 <= 15 )

Show all crashes that occurred between milepost 12 and milepost 15, but exclude those that happened AT milepost 12, 13, 14, and 15.

1.        ( mile_1 > 12 )

2.        ( mile_1 < 15 )

3.        ( mile_1 <> 13 )

4.        ( mile_1 <> 14 )

A single line version of this filter would be:

1.        ( mile_1 > 12 ) & (mile_1 < 15 ) & ( mile_1 <> 13 ) & ( mile_1 <> 14 )

User specific examples

Using user fields in the filter

The filter can be used to show crashes based on the user fields in the database.

Show all crashes coded as rear end collisions

1.        Type_of_Collision =  Rear_End

Show all crashes that were either rear end OR broadside

1.        (Type_Of_Collision = RearEnd) | (Type_Of_Collision = Broadside)

Show all rear end crashes where an injury was involved

1.        Type_Of_Collision = Rear_End

2.        Injuries > 0

or, if the configuration has a severity field...

1.        Type_Of_Collision = Rear_End

2.        Severity = Injury

Show all crashes involving a vehicle turning left and a vehicle moving straight

1.        ((Mov_1=Straight) & (Mov_2=Left)) | ((Mov_2=Straight) & (Mov_1= Left))

Or by using the @ SetMatch function:

1.        @SetMatch(Mov_1,Mov_2,Straight,Left)

Combining user fields and base fields

This actually takes no special arrangements, just use both types of fields.

Show all sideswipe crashes with injuries between 8am and 9am

1.        Type_Of_Collision = Side_Swipe

2.        Injuries > 0

3.        Time >=800

4.        Time <= 900

OR

1.        (Type_Of_Collision=Side_Swipe) & (Injuries>0) & (Time>=800)&(Time<=900)