sumif() (aggregation function)
Returns a sum of Expr for which Predicate evaluates to true.
- Can be used only in context of aggregation inside summarize
You can also use the sum() function, which sums rows without predicate expression.
Syntax
sumif (Expr,Predicate)
Arguments
- Expr: expression for aggregation calculation.
- Predicate: predicate that, if true, the Expr's calculated value will be added to the sum.
Returns
The sum value of Expr for which Predicate evaluates to true.
Example
let T = datatable(name:string, day_of_birth:long)
[
"John", 9,
"Paul", 18,
"George", 25,
"Ringo", 7
];
T
| summarize sumif(day_of_birth, strlen(name) > 4)
| sumif_day_of_birth |
|---|
| 32 |