# RangeMaxString - script and chart function

RangeMaxString() returns the last value in the text sort order that it finds in the expression or field.

Syntax:

RangeMaxString(first\_expr[, Expression])

Return data type: string

Arguments:

The argument of this function may contain inter-record functions which in themselves return a list of values.

* 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. Multiple additional expressions can be used.

Examples:

Examples and results

| Example | Result |
| --- | --- |
| `RangeMaxString<br>(1,2,4)` | Returns 4 |
| `RangeMaxString<br>('xyz','abc')` | Returns 'xyz' |
| `RangeMaxString<br>(5,'abc')` | Returns 'abc' |
| `RangeMaxString<br>(null( ))` | Returns NULL |

Example: (using expression)

`RangeMaxString
 (Above(MaxString(MyField),0,3))`

Returns the last (in text sort order) of the three results of the MaxString(MyField) function evaluated on the current row and two rows above the current row.

Tip noteDisable sorting of MyField to ensure that example works as expected.

Example expression output

| MyField | RangeMaxString(Above(MaxString(MyField),0,3)) |
| --- | --- |
| 10 | 10 |
| abc | abc |
| 8 | abc |
| def | def |
| xyz | xyz |
| 9 | xyz |

**Data used in examples:**

`RangeTab:` `LOAD * INLINE [` `MyField` `10` `'abc'` `8` `'def'` `'xyz'` `9` `] ;`

## Learn more

* [MaxString - chart function](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/ChartFunctions/StringAggregationFunctions/maxstring.htm)