SumIf function
Returns the sum of values in a column, including only the rows that match the specified criteria. Useful for calculating grouped totals based on conditional logic.
Syntax
SumIf(key_column, criteria, sum_range)
Parameters
key_column: The column used to assign values for summation. It groups data and determines how the results are structured. Required
The column containing the entries that the sums will be assigned to.
criteria: The value or column used to filter rows for summation. It determines which rows from the sum_range are included. Note: This parameter accepts an expression, meaning you can provide a literal value, a column reference, or the result of another function. Required
The values in the key_column that will be evaluated.
sum_range
: The column containing the values to be summed. Note: This parameter
accepts an expression, meaning you can provide a literal value, a column reference, or the
result of another function. Required
Return type
Number
Notes:
When using the SumIf function in a filtered transform, it will include filtered values in its sum. The workaround is to filter your table, create a transform off of it, then build the SumIf function in the new table.
Examples
Assume you have the following table:
You want to sum the values for each of the regions and display them in a third column as shown below:
To do this, you would add the Sum column to the table transform and enter the following equation in the Value field:
SumIf(Region,Region,Weight)
Entering "Region" for the criteria argument tells the application to evaluate all entries in the Region column.
Now, suppose you want to add only the values for the Americas. You would use the following equation:
SumIf(Region,"Americas",Weight)
The result:
SumIf(Region, Region, Weight)
: For each row, sums the {Weight} values of
all rows with the same {Region}. Example result:
Region | Weight | FullRegionWeight |
---|---|---|
Americas | 1 | 7 |
Americas | 2 | 7 |
Europe | 3 | 3 |
Americas | 4 | 7 |
Australia | 5 | 11 |
Australia | 6 | 11 |
SumIf(Region, "Americas", Weight
: Returns the sum of {Weight} for rows
where {Region} equals 'Americas'.