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

返回对行的 Expr 非重复值数的估计值,其 Predicate 的求值为 trueReturns an estimate of the number of distinct values of Expr of rows for which Predicate evaluates to true.

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

了解估算精确度Read about the estimation accuracy.

语法Syntax

summarize dcountif(Expr, Predicate, [, Accuracy])summarize dcountif(Expr, Predicate, [, Accuracy])

参数Arguments

  • Expr:用于聚合计算的表达式。Expr: Expression that will be used for aggregation calculation.
  • 谓词:将用于筛选行的表达式。Predicate: Expression that will be used to filter rows.
  • 如果指定,Accuracy 可控制速度和准确性之间的平衡。Accuracy, if specified, controls the balance between speed and accuracy.
    • 0 = 最低准确性和最快计算。0 = the least accurate and fastest calculation. 错误率为 1.6%1.6% error
    • 1 = 默认值,可平衡准确度和计算时间;错误率约 0.8%。1 = the default, which balances accuracy and calculation time; about 0.8% error.
    • 2 = 精确的慢速计算;错误率约 0.4%。2 = accurate and slow calculation; about 0.4% error.
    • 3 = 更精确的慢速计算;错误率约 0.28%。3 = extra accurate and slow calculation; about 0.28% error.
    • 4 = 超级精确的最慢计算;错误率约 0.2%。4 = super accurate and slowest calculation; about 0.2% error.

返回Returns

返回对组中行的 Expr 非重复值数的估计值,这些行的 Predicate 的求值为 trueReturns an estimate of the number of distinct values of Expr of rows for which Predicate evaluates to true in the group.

示例Example

PageViewLog | summarize countries=dcountif(country, country startswith "United") by continent

提示:偏移量错误Tip: Offset error

Predicate 表达式的所有行都通过或没有行通过的极端情况下,dcountif() 可能导致一次性错误dcountif() might result in a one-off error in the edge cases where all rows pass, or none of the rows pass, the Predicate expression