Berserk Docs
Aggregate FunctionsStatistical

avgif

Calculates the average of values in the group for which the predicate evaluates to

Syntax

avgif(val, predicate)

Parameters

Prop

Type

Returns: real

Examples

Example 1

datatable(warrior:string, voyages:long, elite:bool)[
  "Ragnar", 42, true,
  "Bjorn", 31, true,
  "Floki", 12, false,
  "Ivar", 35, true,
  "Harald", 25, false
]
| summarize avgif(voyages, elite)
avgif_voyages (real)
36.0

Example 2

datatable(clan:string, voyages:long, completed:bool)[
  "Lothbrok", 42, true,
  "Lothbrok", 31, false,
  "Fairhair", 25, true,
  "Fairhair", 12, true
]
| summarize avgif(voyages, completed) by clan
clan (string)avgif_voyages (real)
Fairhair18.5
Lothbrok42.0

On this page