avg_if
statisticsAverage of values where mask is true
Syntax
avg_if(values, mask) Parameters
values (array) The values to calculate average from
mask (boolean expression) Condition to filter values
Returns
number The average of values where mask is true
Examples
Average sales in North region
Input:
avg_if(.sales, .region == "North") Output:
45000 Average score of passing students
Input:
avg_if(.score, .passed) Output:
88.5 The avg_if() function calculates the average of values where a condition (mask) is true, enabling conditional aggregation.
Usage
Use avg_if() for calculating averages based on specific criteria, filtering data inline without separate filter operations.