distinctapprox

distinctapprox, function

def nosort process distinctapprox(value: text  ): number
def nosort process distinctapprox(value: number): number

Returns an approximate count of distinct values in a group.

Examples

table T = with
  [| as Group, as Value |]
  [| "A", 1 |]
  [| "A", 1 |]
  [| "A", 2 |]
  [| "B", 2 |]
  [| "B", 3 |]

table G[g] = by T.Group
G.Count = distinctapprox(T.Value)

show table "Distinct approx" with
  g as "Group"
  G.Count as "Count"

This produces the following table:

Group Count
A 2
B 2

Remarks

distinctapprox is designed for large groups and uses a probabilistic approximation internally; for small groups, it often matches distinct.

See also

User Contributed Notes
0 notes + add a note