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

返回 Predicate 对其的计算结果为 true 的行数。Returns a count of rows for which Predicate evaluates to true. 只能在 summarize 内的聚合上下文中使用。Can only be used only in context of aggregation inside summarize.

语法Syntax

汇总 countif(Predicate)summarize countif(Predicate)

参数Arguments

谓词 :用于聚合计算的表达式。Predicate : Expression that will be used for aggregation calculation. Predicate 可以是返回类型为 bool 的任何标量表达式(计算结果为 true/false)。Predicate can be any scalar expression with return type of bool (evaluating to true/false).

返回Returns

返回 Predicate 对其的计算结果为 true 的行数。Returns a count of rows 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 countif(strlen(name) > 4)
countif_countif_
22

请参阅See also

count() 函数,用于在没有谓词表达式的情况下计算行数。count() function, which counts rows without predicate expression.