Type: Function
Function: SUM_IF
Syntax: SUM_IF(condition, number)
Description: Sum a field or expression matching the provided condition, for each grouping (set of dimensions).
This aggregator is useful when comparing multiple metrics side by side, such as when creating a chart with multiple series. If your insight only contains one metric then use a SUM
in combination with standard filters, this will accelerate your report and make the configuration easier to maintain.
Example use case:
You want to compare the total number of lines of code changed for all pull requests versus those that are currently open.
To do so, you can create a Line Chart with one dimension (e.g. created_at
) and the following two metrics: A plain SUM
on lines_changed
metric, which sums all lines of code changed A custom formula SUM_IF(state == “OPEN”, lines_changed)
, which sums the lines of code from open pull requests only.
Sample usage:
SUM_IF(state == "MERGED", additions)
returns the sum of theadditions
field value for all merged pull requests.SUM_IF(CONTAINS(requested_reviewer_usernames,"johndoe"), required_approval_remaining_count)
returns the sum of therequired_approval_remaining_count
field value for all pull requests pending review from “johndoe”.