Function Problems

How to Count Invoices by Contract in Excel Without a Helper Column

Olivia MillerOlivia Miller Nov 2, 2026 869 views

Question details

The user needs to dynamically count the number of nonblank invoices associated with each contract without relying on helper columns or manually refreshing a pivot table.

Count Invoices by Contract in Excel Without a Helper Column
Product
Excel
Device & OS
not provided
Scenario
Managing a large master dataset (e.g., 9,400 contracts) that feeds charts, requiring automatic and dynamic updates when new invoices are added or removed.
Observed behavior
The goal is to automatically output a list of unique contracts alongside their respective nonblank invoice counts directly within the spreadsheet, avoiding manual intervention.
Before you start

Ensure your dataset is formatted as an official Data Table (Ctrl+T) so that formulas automatically expand to include new rows, and verify your spreadsheet software supports dynamic arrays if using advanced functions.

Solution 1Recommended

Use a Dynamic Array Formula (LET, UNIQUE, and HSTACK)

This method utilizes modern dynamic array functions to generate both the unique list of contracts and their respective invoice counts in a single step.

By combining LET, UNIQUE, FILTER, and HSTACK, you can create a single formula that reads the master data, extracts unique contracts, and tallies the nonblank invoices for each. Because it uses structured table references, the results scale dynamically as data changes.

1
Identify your table and column names

Confirm the name of your table (e.g., Table1) and the specific columns for contracts (Table1[Contract]) and invoices (Table1[Invoice]).

2
Select the destination cell

Click on the top-left cell where you want the dynamic list of contracts and counts to begin.

3
Enter the dynamic formula

Type the formula: =LET(contracts,FILTER(Table1[Contract],Table1[Contract]<>""),uniqueContracts,UNIQUE(contracts),HSTACK(uniqueContracts,COUNTIFS(Table1[Contract],uniqueContracts,Table1[Invoice],"<>")))

4
Execute the formula

Press Enter. The formula will automatically spill the unique contract names in the first column and their nonblank invoice counts in the adjacent column.

Use a Dynamic Array Formula (LET, UNIQUE, and HSTACK)
Dynamic Spilling: This method requires no manual dragging or helper columns and automatically scales as your master data updates, perfectly feeding automated charts.
Advanced Spreadsheets Data Analysis

Effortlessly Count and Manage Complex Data in WPS Spreadsheets

WPS Office provides robust formula support, fully handling complex master datasets and advanced COUNTIFS functions without slowing down your system.

  1. 1. Import your dataset: Open your large master dataset securely in WPS Spreadsheets.
  2. 2. Format as a Data Table: Select your dataset and press Ctrl+T to convert it into a dynamic table.
  3. 3. Apply advanced functions: Input your COUNTIFS or dynamic formulas to instantly generate accurate invoice counts.
  4. 4. Connect to charts: Highlight your dynamically generated data and insert a chart from the Insert tab to create a real-time dashboard.
Fully compatible with Microsoft Excel formulas, tables, and structured references.Handles large datasets with thousands of rows efficiently.Supports dynamic automated charts that link directly to your formula outputs.A free, lightweight, and fast alternative to heavy spreadsheet programs.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my dynamic array formula returning a #SPILL! error?

A #SPILL! error occurs when the formula's output range is blocked by existing data or text. Clear all the cells below and to the right of your formula cell to allow the array results to expand and populate properly.

Can I use a Pivot Table instead of formulas for counting invoices?

Yes, Pivot Tables are excellent for summarizing data. You can place 'Contract' in the Rows area and 'Invoice' in the Values area (set to Count). However, unlike dynamic formulas, you must manually refresh the Pivot Table (Right-click > Refresh) whenever your source data changes.

How do I count only specific types of invoices using COUNTIFS?

You can add additional criteria ranges and conditions to your COUNTIFS function. For example, =COUNTIFS(Table1[Contract], "Contract A", Table1[Invoice], "<>", Table1[Status], "Paid") will only count nonblank invoices that are marked specifically as paid.

Are functions like LET and HSTACK supported in older versions of Excel?

No, dynamic array functions like LET, HSTACK, and UNIQUE require modern versions of spreadsheet software, such as Microsoft 365, Excel 2021, or the latest editions of WPS Office. For older versions, you must rely on traditional COUNTIFS coupled with a manually generated unique list.