Expression: Selector Functions

The following functions are available to map the values from selector variables to strings and numerics.  Once mapped they can be used with any functions and operators that support those types.

A selector variable has coded categories like PostArea or Income Band.  Each category has a code and a description.

An Income band category might look like this:

Code

Description

00

Unclassified

01

< 10k

02

10-20k

03

20-30k

04

30-40k

CodeOf

 

Returns the code of the selector variable

 

CodeOf([Selector Variable])

 

CodeOf([Income Band]) = "04"

 

DescOf

 

Returns the decode description of the selector variable

 

DescOf([Selector Variable])

 

DescOf([Income Band]) = “30 – 40k”

 

ValueOf

 

Returns the description of the selector variable as a number

 

ValueOf([Selector Variable])

 

ValueOf([Income Band]) = 30 as it just takes the first number

 

IndexOf

 

Returns the index of the code of the selector variable as a number

 

IndexOf([Selector Variable])

 

IndexOf([Income Band]) is 4.  Unclassified is zero

 

InstantCountOf

Returns the 'instant count' of the selector variable as a number

 

InstantCountOf([Income]) e.g. £100k+ = 53

 

In this example 53 people have an income of £100k+

 

VarSelect

Returns the index of the given code for the given selector variable if the record in question has one of the code values set

 

VarSelect([Income], "01", "02", "03")

 

1 for all records that have an Income value with code "01", 2 for all records that have an Income value with code "02", 3 for all records that have an Income value with code "03" and blank otherwise

 

Cardinality of

Returns the number of category codes for selector variables

 

VarDesc

Returns the description for a selector variable category:

 

VarDesc([myVar],"code") returning the description for the corresponding code

or

VarDesc([myVar],N) returning the description corresponding to index N

 

VarDesc([myVar],CreateSet(2,3)) - returns a delimited string of descriptions corresponding to the indexes in the set

VarSelectCode

Returns the first matched code based on each selector variable evaluating along the parameters.

Multiple sets of selector variable and values lists can be used. For example:

 

VarSelectCode ([postsect], ”CV34 3”, ”CV34 4”, [postdist], ”CV31” , [postarea], ”B”,”OX”)

 

Specifying the optional "AsDesc" presents the output as descriptions, if these are available.

NthSelectedFlag

Returns the description of the Nth selected flag in a flag array

 

If N is negative then the Nth from last is selected

NthIndexSelectedFlag

Returns the index of the Nth selected flag in a flag array

 

If N is negative then the Nth from last is selected