Investment Studio > Expressions > Functions > Reference > MATCH

integer match(lookup_value, array[*][*] table, integer match_type = 1)

Returns the position (order of appearance) of lookup_value in table, using the specified match_type:

match_type Result
= 1 or omitted Position of largest value <= lookup_value.
= -1 Position of smallest value >= lookup_value.
= 0 Position of first exact match.

Matching follows the same rules as the comparison operators, with the following extension: if match_type = 0 and lookup_value is a string, lookup_value can contain the wildcard characters "*" and "?". An asterisk matches any character sequence. A question mark matches any single character.

If no match is found, the result is an error (#N/A).

Examples

=match(2.5, {{6, 5, 4}, {3, 2, 1}})

returns 5 (position of 2, largest value <= 2.5)

=match(2.5, {{6, 5, 4}, {3, 2, 1}}, -1)

returns 4 (position of 3, smallest value >= 2.5)

=match(2.5, {{6, 5, 4}, {3, 2, 1}}, 0)

is an error (#N/A): there is no exact match

=match("F?do", {"Friday", "Frodo", "Fido"}, 0)

returns 3 (position of "Fido", exact match to "F?do", with wildcard)

=match("F*do", {"Friday", "Frodo", "Fido"}, 0)

returns 2 (position of "Frodo", first exact match to "F*do", with wildcard).

See also hlookup, index, lookup, vlookup.