variancepif() (aggregation function)
Learn how to use the variancepif() function to calculate the variance in an expression where the predicate evaluates to true.
Calculates the variance of expr in records for which predicate evaluates to true.
Syntax
variancepif(expr, predicate)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| expr | string | ✔️ | The expression to use for the variance calculation. |
| predicate | string | ✔️ | If predicate evaluates to true, the expr calculated value will be added to the variance. |
Returns
Returns the variance value of expr in records for which predicate evaluates to true.
Example
This query generates a sequence of numbers from 1 to 100 and then calculates the variance of the even numbers within that sequence.
range x from 1 to 100 step 1
| summarize variancepif(x, x%2 == 0)
Output
| variancepif_x |
|---|
| 850 |
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.