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

返回一个 dynamic (JSON) 数组,该数组包含 Expr 在组中接受的非重复值集,其 Predicate 的计算结果为 trueReturns a dynamic (JSON) array of the set of distinct values that Expr takes in the group, for which Predicate evaluates to true.

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

语法Syntax

summarize make_set_if(Expr, Predicate [, MaxSize])summarize make_set_if(Expr, Predicate [, MaxSize])

参数Arguments

  • Expr:用于聚合计算的表达式。Expr: Expression that will be used for aggregation calculation.
  • 谓词:必须计算为 true 的谓词,用于将“Expr”添加到结果中。Predicate: Predicate that has to evaluate to true for Expr to be added to the result.
  • MaxSize 是对返回元素最大数目的可选整数限制(默认值是 1048576)。MaxSize is an optional integer limit on the maximum number of elements returned (default is 1048576). MaxSize 值不能超过 1048576。MaxSize value cannot exceed 1048576.

返回Returns

返回一个 dynamic (JSON) 数组,该数组包含 Expr 在组中接受的非重复值集,其 Predicate 的计算结果为 trueReturns a dynamic (JSON) array of the set of distinct values that Expr takes in the group, for which Predicate evaluates to true. 数组的排序顺序未定义。The array's sort order is undefined.

提示

若要仅对非重复值进行计数,请使用 dcountif()To only count the distinct values, use dcountif()

另请参阅See also

make_set 函数,它在无谓词表达式的情况下执行相同的操作。make_set function, which does the same, without predicate expression.

示例Example

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