You are here: Functions > MATCH()

MATCH()

MATCH() compares an expression or field value (character, numeric or date) to a series of specified expressions, field values or variable arrays of the same type to determine whether there is at least one match. The value returned is either true or false. Use MATCH() to eliminate the need to repeat arguments in a test.

Use of variable arrays as a parameter is supported for this function. This means that a list of values can be provided using a single variable array. For more information see Variable Arrays.

Function Format

MATCH(comparison_value,test1,test2 <,test 3...>)

MATCH() returns a true or false value, depending on whether the comparison value is equal to any of the subsequent test values. Any number of test values can be included, each consisting of a constant, field value or expression. The test values can be of any type (character, numeric, date or logical), as long as all are of the same type.

If a variable array is used as one of the parameters, all values in contained in the variable array are compared in conjunction with any other listed parameters.

Using this function you can replace:

IF LOC = "01" OR LOC = "02" OR LOC = "13" OR LOC = "22"

with the condition:

IF MATCH(LOC,"01","02","13","22")

Examples

The following three examples test whether a value is found in a list of values:

MATCH(7,1,3,5,7,9) = T because 7 is included in the list 1, 3, 5, 7, 9

MATCH(7,2,4,6,8,10) = F because 7 is not included in the list 2, 4, 6, 8, 10

MATCH('BILL','JOHN','ANDY') = F because BILL is not included in the list of JOHN or ANDY.

If locations 01, 02, 13 and 22 represent your research divisions, to create a Research filter that excludes all other departments, specify the condition:

MATCH(LOC,"01","02","13","22")

Note: To extract all records for the research division, enter Research in the If condition text box of the Extract command.

If you want to review a payroll file to view only employees that worked on Christmas Day 2011 or New Years Day 2012, specify the condition:

MATCH(WORK_DATE,‘20111225‘,‘20120101‘)

Note: The date values are entered as YYYYMMDD regardless of the date format of the DATE field being referenced.

If you want to compare a last name field to a known list of former employees last names that is stored in a variable array, specify the condition:

MATCH(LAST_NAME,ARRAY_FORMER_EMPLOYEES)

Note: To create the variable array, the list of former employees would have been defined and then the last name field for the former employees would have been saved to a variable array using the SAVE FIELD command. For more information see Save.