Running Count with Structured References in Google Sheets

Published on

Running a count with structured references is achievable in Google Sheets tables using the COUNTIF function. Here is the generic formula:

=COUNTIF(first:current, current)

The key question is how to identify the first and current row values dynamically.

If your table, named Table1, has a column titled “Sales Platform” and you want to calculate a running count of sales platforms, whether the data is sorted or unsorted, the formula would look like this:

=COUNTIF(INDEX(Table1[Sales Platform], 1):SINGLE(Table1[Sales Platform]), SINGLE(Table1[Sales Platform]))

Explanation:

  • first: Refers to the first value in the column, derived using the formula: INDEX(Table1[Sales Platform], 1)
  • current: Refers to the value in the current row, extracted using: SINGLE(Table1[Sales Platform])

Example of Running Count with Structured Table References

In the example below, the table named Table1 occupies the range B2:D10.

To calculate the running count:

  1. Enter the formula in cell D3: =COUNTIF(INDEX(Table1[Sales Platform], 1):SINGLE(Table1[Sales Platform]), SINGLE(Table1[Sales Platform]))
  2. Drag the formula down from D3 to D10.
Example of a running count calculated using structured table references in Google Sheets

This calculates the running count of occurrences in the range B3:B10.

Using Array Formulas for Running Count with Structured References

You can also calculate the running count using an array formula. With this approach, you don’t need to separately extract the first and current cell values.

Generic formula:

=ArrayFormula(COUNTIFS(column, column, ROW(column), "<="&ROW(column)))

For the example data:

=ArrayFormula(COUNTIFS(Table1[Sales Platform], Table1[Sales Platform], ROW(Table1[Sales Platform]), "<="&ROW(Table1[Sales Platform])))
  1. Clear the range D3:D10.
  2. Enter this formula in cell D3.

This formula conditionally counts the values in the column up to the current row for each row.

Things to Know

Drag-Down Formula:

  • When adding a new row at the bottom (e.g., in cell B11), simply enter data in B11. The table will automatically expand, and the formula in D10 will copy to D11.
  • Avoid using the “+” button that appears when you hover over B10 to add a new row.
  • To insert rows between existing records, use the Insert menu > Row below option. Here, you can also use the “+” button.

Array Formula:

  • When adding a new row at the bottom, either use the “+” button or enter the data directly below the last row—both methods work.
  • When inserting a new row between existing data, use the Insert menu command.

Additional Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Running Total with Structured Table References in Google Sheets

You can use two types of formulas to create a running total with structured...

Automate Multi-Colored Line Charts in Google Sheets

Usually, a line chart with a single line supports only one color. To create...

Calculate the Number of Nights in Each Month in Google Sheets

When working with date ranges, such as check-in and check-out dates, it’s often useful...

Excel Tutorial: Calculate Nights Between Dates in Each Month

When working with date ranges in Excel, you might need to calculate how many...

More like this

Running Total with Structured Table References in Google Sheets

You can use two types of formulas to create a running total with structured...

Automate Multi-Colored Line Charts in Google Sheets

Usually, a line chart with a single line supports only one color. To create...

Calculate the Number of Nights in Each Month in Google Sheets

When working with date ranges, such as check-in and check-out dates, it’s often useful...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.