Skip to main content
COUNT_IF
Tom Williams avatar
Written by Tom Williams
Updated over a year ago

Type: Aggregator

Function: COUNT_IF

Syntax: COUNT_IF(condition)

Description: Count the number of records matching the provided condition, in each group (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 COUNT 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 commits versus the number of commits related to a fix (the commit message contains the “fix” keyword).

To do so, you can create a Line Chart using the Commits dataset with one dimension (e.g. created_at) and the following two metrics: A plain COUNT metric, which counts the number of commits A custom formula COUNT_IF(message ~ “fix”), which counts the number of commits having the “fix” keyword in their commit message

Sample usage:

  • COUNT_IF(state=="CLOSED" || state=="MERGED") counts the number of records that are either closed or merged.

  • COUNT_IF(author_username ~ "doe$") counts the number of records where the author’s name ends with "doe".

  • (COUNT_IF(CONTAINS(label_names, ["bug", "fix"]))/COUNT())*100 returns the percentage of records labeled as "bug or "fix" amongst all records.

Did this answer your question?