# RangeMax - 脚本和图表函数

RangeMax() 用于返回在表达式或字段内找到的最高数值。

语法：

RangeMax(first\_expr[, Expression])

返回数据类型： 数字

参数：

* first\_expr： 表达式或字段包含要度量的数据。
* Expression： 可选表达式或字段包含要度量的数据范围。 可以使用多个附加表达式。

限制：

如果找不到任何数值，则返回 NULL 值。

示例：

示例和结果

| 示例 | 结果 |
| --- | --- |
| `RangeMax<br>(1,2,4)` | 返回 4 |
| `RangeMax<br>(1,'xyz')` | 返回 1 |
| `RangeMax<br>(null( ), 'abc')` | 返回 NULL |

示例： （使用表情）

`RangeMax
 (Above(MyField,0,3))`

返回在当前行和当前行上方两行中计算的三个 MyField 字段值范围的最大值。通过指定第三个参数作为 3，Above() 函数会返回三个值，如果上方有足够的行，会将其作为 RangeMax() 函数的输入。

提示注释禁用 MyField 排序可确保示例符合预期。

示例表达式输出

| MyField | RangeMax (Above(Sum(MyField),1,3)) |
| --- | --- |
| 10 | 10 |
| 2 | 10 |
| 8 | 10 |
| 18 | 18 |
| 5 | 18 |
| 9 | 18 |

**示例中所使用的数据：**

`RangeTab:` `LOAD * INLINE [` `MyField` `10` `2` `8` `18` `5` `9` `] ;`

示例： (表格形式）

将示例脚本添加到文档并运行。然后，至少要将结果列中列出的字段添加到文档中的表格才能查看结果。

`RangeTab3:` `LOAD recno() as RangeID, RangeMax(Field1,Field2,Field3) as MyRangeMax INLINE [` `Field1, Field2, Field3` `10,5,6` `2,3,7` `8,2,8` `18,11,9` `5,5,9` `9,4,2`

`];`

结果列表显示了为表格中的每条记录返回的 MyRangeMax 值。

表格形式的输出示例

| RangeID | MyRangeMax |
| --- | --- |
| 1 | 10 |
| 2 | 7 |
| 3 | 8 |
| 4 | 18 |
| 5 | 9 |
| 6 | 9 |

## 了解详情

* [Max](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/ChartFunctions/BasicAggregationFunctions/max.htm)
* [RangeMax - 脚本和图表函数](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/ChartFunctions/RangeFunctions/rangemax.htm#)