Skip to main content

Add row count as an available value in Chart formulas

Extend Chart formulas to support arithmetic operations using the number of rows/groups returned by the Chart.

Currently, formulas can use existing metrics and calculated values, but there is no way to use the number of resulting rows after grouping as part of a calculation.

This is required for calculating metrics where the denominator is the number of unique grouped entities.

Example Use Case

A Chart is grouped by unique customer phone number.

For each unique number, the Chart contains the number of repeat calls.

We need to calculate the average number of repeat calls per unique customer:

Sum of repeat calls / Number of unique phone numbers

Since grouping by phone number produces one row per unique number, the denominator should be the number of rows produced by the grouping.

Example:

  • Unique phone numbers: 100

  • Total repeat calls: 250

  • Result: 250 / 100 = 2.5

Average repeat calls per unique number = 2.5.

Required Changes

Add a value/function to Chart formulas that represents the number of rows in the current grouped result.

For example:

ROW_COUNT

or another naming consistent with the existing formula syntax.

This value should be available as an operand in arithmetic expressions together with existing metrics.

Example formula:

SUM(Repeat Calls) / ROW_COUNT

Expected Behavior

  • When a Chart is grouped by a field, row count represents the number of resulting groups.

  • If the Chart is grouped by unique phone number, row count represents the number of unique phone numbers in the result.

  • Row count can be used in arithmetic operations with other Chart metrics.

  • Row count respects the filters and date range applied to the Chart.

  • If filters change the number of resulting groups, the formula result is recalculated accordingly.

Acceptance Criteria

  1. Chart formulas can use the number of resulting rows/groups as a calculation value.

  2. Row count can be combined with existing metrics using arithmetic operations.

  3. When grouping by a unique field, row count matches the number of unique grouped values.

  4. Row count respects all filters applied to the Chart.

  5. Row count respects the selected date range.

  6. Formula results are recalculated when grouping, filters, or date range are changed.

  7. The functionality can be used to calculate average values such as:

    Total repeat calls / Number of unique customers

    Origin

Log in to comment and vote

No comments yet

Be the first to share your thoughts.