sumif()(聚合函数)sumif() (aggregation function)

返回谓词计算结果为 true 的“Expr”的总和。Returns a sum of Expr for which Predicate evaluates to true.

  • 只能在 summarize 内的聚合上下文中使用Can be used only in context of aggregation inside summarize

还可以使用 sum() 函数,该函数在没有谓词表达式的情况下对行求和。You can also use the sum() function, which sums rows without predicate expression.

语法Syntax

summarize sumif(Expr,Predicate)summarize sumif(Expr,Predicate)

参数Arguments

  • Expr:用于聚合计算的表达式。Expr : expression for aggregation calculation.
  • Predicate:谓词,如果为 true,则 Expr 的计算值将添加到总和。Predicate : predicate that, if true, the Expr 's calculated value will be added to the sum.

返回Returns

返回谓词计算结果为 true 的 Expr 总和值。The sum value of Expr for which Predicate evaluates to true.

示例Example

let T = datatable(name:string, day_of_birth:long)
[
   "John", 9,
   "Paul", 18,
   "George", 25,
   "Ringo", 7
];
T
| summarize sumif(day_of_birth, strlen(name) > 4)
sumif_day_of_birthsumif_day_of_birth
3232