Skip to content
HPCCSystems Solutions Lab
HPCCSystems Solutions Lab

MAP Function

MAP function evaluates the list of Boolean expressions and returns the value associated with the first true expression.

MAP Characteristics

  • If no match is found than the else-value is returned
  • All return values and else_value values must be of the same type
  • All expressions must reference the same level of dataset scoping. Therefore, all expressions must either reference fields in the same dataset or the existence of a set of related child records
  • The expressions are evaluated in the order in which they appear.

Syntax

attr_name := MAP(expression1 => value1,
                 expression2 => value2,
                 ...
                 ...
                 expressionN => valueN
                 [,else_value]
                 )

ValueDefinition
attr_nameThe name by which the function will be invoked
MAPECL Keyword, required
Expression1…NBoolean expression
=>“Result in” operator
Else_valueOptional if all other possible return values are actions, otherwise required. The value to return if all expressions are false.

#### Example
/*
MAP Example:
*/

Value := 120;

Assessment := MAP(Value BETWEEN  0   AND 50   => 'Under Estimated',
                  Value BETWEEN  51  AND 100  => 'About Right',
                  Value BETWEEN  101 AND 150  => 'Still Acceptable',
                  Value BETWEEN  151 AND 200  => 'Too High',
                 'Rejected');

OUTPUT(Assessment, NAMED('Assessment'));
Try Me

Logical Operators

Logical values that can be used for comparison of two values.


Demo Dataset

PersonIDFirstNameLastNameisEmployedavgHouseIncome
102FredSmithFALSE0
012JoeBlowTRUE11250
085BlueMoonTRUE185000
055SilverJoFALSE5000
265DarlingJoTRUE5000
333JaneSmithFALSE50000


/*
MAP Example:
Using logical operations
*/


Value  := 100;
Flag   := False;
Letter := 'A';

Assessment := MAP(Value BETWEEN  0   AND 50    OR  Flag  => 'Under Estimated',
                  Value BETWEEN  51  AND 100  AND ~Flag => 'About Right',
                  Value BETWEEN  101 AND 150 AND ~Flag AND Letter = 'A' => 'Still Acceptable',
                  Value BETWEEN  151 AND 200 => 'Too High',
                  'Rejected');

OUTPUT(Assessment, NAMED('Assessment'));
Try Me

Logical Operators

Logical values that can be used for comparison of two values.


OperatorDescription
=Equal
>Greater than
<Less than
>=Greater than or equal
<=Less than or equal
<>Not equal
!=Not equal
~Not
ANDLogical AND
ORLogical OR
INTo specify multiple possible values for a field/column
NOT INTo specify multiple possible values that are not in a field/column
BETWEENBetween a certain range