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.

Top N Products and Top N Sellers in Google Sheets (Top N of Top N)

If you’ve ever wanted to compare which sellers contribute the most to your top-selling...

Use XLOOKUP in a Structured Table in Google Sheets (Single and Multiple Conditions)

This tutorial is for users who want to apply XLOOKUP inside a structured table...

Reset SCAN by Another Column in Google Sheets and Excel

Resetting SCAN function results based on values in another column is a topic of...

How to Get the Fastest Time for Each Person in Google Sheets

Whether you’re tracking race results, event times, or any other timed activities, finding the...

More like this

Top N Products and Top N Sellers in Google Sheets (Top N of Top N)

If you’ve ever wanted to compare which sellers contribute the most to your top-selling...

Use XLOOKUP in a Structured Table in Google Sheets (Single and Multiple Conditions)

This tutorial is for users who want to apply XLOOKUP inside a structured table...

How to Get the Fastest Time for Each Person in Google Sheets

Whether you’re tracking race results, event times, or any other timed activities, finding the...

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.