RangeMode - script and chart function
RangeMode() finds the most commonly occurring value (mode value) in the expression or field.
Syntax:
RangeMode(first_expr {, Expression})
Return data type: numeric
Arguments:
The argument expressions of this function may contain inter-record functions with a third optional parameter, which in themselves return a range of values.
Argument | Description |
---|---|
first_expr | The expression or field containing the data to be measured. |
Expression | Optional expressions or fields containing the range of data to be measured. |
Limitations:
If more than one value shares the highest frequency, NULL is returned.
Examples and results:
Examples | Results |
---|---|
RangeMode (1,2,9,2,4) |
Returns 2 |
RangeMode ('a',4,'a',4) |
Returns NULL |
RangeMode (null( )) |
Returns NULL |
Example with expression:
RangeMode (Above(Sum(Temperature),0,3))
Returns the most commonly occurring value in the three results of the Sum(Temperature) function evaluated on the current row and two rows above the current row.
Data used in example:
Region | City | Temperature | RangeMode(Above(Sum(Temperature),0,3)) |
---|---|---|---|
A | A | 18 |
18 |
A | B | 17 | - |
A | C | 16 | - |
A | D | 18 | - |
A | E | 16 | 16 |
A | F | 20 | - |
A | G | 22 | - |
A | H | 20 | 20 |
Example with expression on a single field with Sum():
RangeMode (Above(Sum(MyField),0,3))
Returns the most commonly occurring value in the three results of the Sum(MyField) function evaluated on the current row and two rows above the current row.
Data used in example:
MyField | Sum(MyField) | RangeMode(Above(Sum(MyField),0,3)) |
---|---|---|
10 | 10 | Returns 10 because there are no rows above so the single value is the most commonly occurring. |
2 | 2 | |
8 | 8 | |
18 | 18 | |
5 | 5 | |
9 | 18 | Returns 18 because RangeMode is evaluating Sum(MyField) where 18 occurs twice in 3 rows. |
7 | 7 | |
9 |
angeTemp:
LOAD * INLINE [
Region|City|Temperature
A|A|18
A|B|17
A|C|16
A|D|18
A|E|16
A|F|20
A|G|22
A|H|20
] (delimiter is '|');
Learn more
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!