PowerApps 中的 Average、Max、Min、StdevP、Sum 和 VarP 函数Average, Max, Min, StdevP, Sum, and VarP functions in PowerApps

用于对一组数字进行汇总的聚合函数。Aggregate functions that summarize a set of numbers.


Average 函数可用于计算其参数的平均值(或算术平均值)。The Average function calculates the average, or arithmetic mean, of its arguments.

Max 函数用于查找最大值。The Max function finds the maximum value.

Min 函数用于查找最小值。The Min function finds the minimum value.

Sum 函数可用于对其参数求和。The Sum function calculates the sum of its arguments.

StdevP 函数可用于计算其参数的标准偏差。The StdevP function calculates the standard deviation of its arguments.

VarP 函数可用于计算其参数的方差。The VarP function calculates the variance of its arguments.

可以按如下形式为这些函数提供值:You can supply the values for these functions as:

  • 分别列出每个参数。Separate arguments. 例如,Sum( 1, 2, 3 ) 会返回 6。For example, Sum( 1, 2, 3 ) returns 6.
  • 一个和一个对表进行运算的公式。A table and a formula to operate over that table. 通过公式对每条记录的值计算聚合。The aggregate will be calculated on the values of the formula for each record.

当前正在处理的记录字段在该公式中可用。Fields of the record currently being processed are available within the formula. 只需按名称对其引用,这与引用任何其他值的方法相同。You simply reference them by name as you would any other value. 另外,也可以从整个应用中引用控件属性和其他值。You can also reference control properties and other values from throughout your app. 有关详细信息,请参阅下面的示例和使用记录作用域For more details, see the examples below and working with record scope.

这些函数只能对数值进行运算。These functions operate on numeric values only. 它们会忽略其他类型的值(例如字符串或记录)。Other types of values, such as strings or records, are ignored. 可使用 Value 函数将字符串转换成数值。Use the Value function to convert a string into a number.

当与支持这些函数的委派的数据源结合使用时,可以委派 Average、Max、Min 和 Sum 函数。The Average, Max, Min, and Sum functions can be delegated when used with a data source that supports delegation for these functions. 但是,不能为任何数据源委派 StdevP 和 VarP。However, StdevP and VarP can't be delegated for any data sources. 如果不支持委派,则只会检索数据的第一个部分,然后本地应用函数。If delegation is not supported, only the first portion of the data will be retrieved and then the function applied locally. 结果可能并不是事实的全部。The result may not represent the complete story. 系统会在你创作时显示一个蓝点,提醒注意此限制,并建议尽可能改用可委托的替代项。A blue dot will appear at authoring time to remind you of this limitation and to suggest switching to delegable alternatives where possible. 有关详细信息,请参阅委托概述For more information, see the delegation overview.


Average( NumericalFormula1, [ NumericalFormula2, ... ] )Average( NumericalFormula1, [ NumericalFormula2, ... ] )
Max( NumericalFormula1, [ NumericalFormula2, ... ] )Max( NumericalFormula1, [ NumericalFormula2, ... ] )
Min( NumericalFormula1, [ NumericalFormula2, ... ] )Min( NumericalFormula1, [ NumericalFormula2, ... ] )
Sum( NumericalFormula1, [ NumericalFormula2, ... ] )Sum( NumericalFormula1, [ NumericalFormula2, ... ] )
StdevP( NumericalFormula1, [ NumericalFormula2, ... ] )StdevP( NumericalFormula1, [ NumericalFormula2, ... ] )
VarP( NumericalFormula1, [ NumericalFormula2, ... ] )VarP( NumericalFormula1, [ NumericalFormula2, ... ] )

  • NumericalFormula(s) - 必需。NumericalFormula(s) - Required. 要运算的数值。Numeric values to operate on.

Average( Table, NumericalFormula )Average( Table, NumericalFormula )
Max( Table, NumericalFormula )Max( Table, NumericalFormula )
Min( Table, NumericalFormula )Min( Table, NumericalFormula )
Sum( Table, NumericalFormula )Sum( Table, NumericalFormula )
StdevP( Table, NumericalFormula )StdevP( Table, NumericalFormula )
VarP( Table, NumericalFormula )VarP( Table, NumericalFormula )

  • Table - 必需。Table - Required. 要运算的表。Table to operate on.
  • NumericalFormula - 必需。NumericalFormula - Required. 用于对每条记录求值的公式。Formula to evaluate for each record. 这个公式的结果用于聚合。The result of this formula is used for the aggregation. 你可以在公式中使用的表的列。You can use columns of the table in the formula.


分步操作Step by step

假设有一个名为 Sales数据源,其中包含 CostPerUnit 列和 UnitsSold 列,并且将一个标签的 Text 属性设置为以下函数:Let's say that you had a data source named Sales that contained a CostPerUnit column and a UnitsSold column, and you set the Text property of a label to this function:
Sum(Sales, CostPerUnit * UnitsSold)Sum(Sales, CostPerUnit * UnitsSold)

这个标签会显示总销售额,计算方法如下:对每条记录,将这两列中的值相乘,然后将所有记录的计算结果相加。The label would show total sales by multiplying the values in those columns for each record and then adding the results from all records together:

再举一个例子,假设有几个滑块,分别名为 Slider1Slider2Slider3,还有一个标签,其 Text 属性设置为以下公式:As a different example, let's say that you had sliders that were named Slider1, Slider2, and Slider3 and a label with its Text property set to this formula:
Sum(Slider1.Value, Slider2.Value, Slider3.Value)Sum(Slider1.Value, Slider2.Value, Slider3.Value)

这个标签会显示为滑块设置的所有值的总和。The label would show the sum of all values to which the sliders were set.