any

any, function

def nosort process any(value: boolean): boolean default false

Returns true when at least one value in value is true. For an empty group, it returns false.

Examples

table T = with
  [| as Id, as HasError |]
  [| "a",   false       |]
  [| "b",   true        |]
  [| "c",   false       |]

hasAnyError = any(T.HasError)

show table "Any errors" with hasAnyError

Output:

hasAnyError
true
table T = with
  [| as Category, as HasIssue |]
  [| "A",         false       |]
  [| "A",         false       |]
  [| "B",         true        |]
  [| "C",         false       |]

table Categories = with
  [| as Category |]
  [| "A" |]
  [| "B" |]
  [| "C" |]
  [| "D" |] // empty group

Categories.HasAnyIssue = any(T.HasIssue) by T.Category at Categories.Category

show table "Issue detection" with
  Categories.Category
  Categories.HasAnyIssue

Output:

Category HasAnyIssue
A false
B true
C false
D false

Remarks

The any aggregator is marked nosort because ordering does not affect logical OR.

See also

User Contributed Notes
0 notes + add a note