Function Problems

Excel Formulas to Sum and Count Unique IDs by Status and Date

Algirdas JasaitisAlgirdas Jasaitis Nov 18, 2026 872 views

Question details

Create formulas that use status and date criteria to count unique identifiers and calculate totals.

Excel Formulas to Sum and Count Unique IDs by Status and Date
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains records with identifiers, statuses, timestamps, and amounts. The user wants to filter records for a chosen day and summarize them by unique identifier.
Observed behavior
The desired results are a unique ID count and totals that include all matching timestamps on the chosen date.
Before you start

Confirm whether duplicate IDs should be counted once and whether their matching amounts should all be added. The examples use IDs in A2:A100, statuses in B2:B100, timestamps in C2:C100, amounts in D2:D100, and a date without a time in F1.

Solution 1Recommended

Use Excel dynamic array formulas to count IDs and total amounts

Use this approach in a version of Excel that supports LET, FILTER, UNIQUE, MAP, and HSTACK.

These formulas count each nonblank ID once and add every matching amount for that ID. They select timestamps from the start of the date in F1 up to, but not including, the following day.

1
Enter the target date

Enter a valid Excel date with no time component in F1. Replace "Open" in the formulas with the status you need.

2
Count matching unique IDs

In an empty cell, enter =IF(COUNTIFS(B2:B100,"Open",C2:C100,">="&F1,C2:C100,"<"&F1+1,A2:A100,"<>")=0,0,ROWS(UNIQUE(FILTER(A2:A100,(B2:B100="Open")*(C2:C100>=F1)*(C2:C100<F1+1)*(A2:A100<>""))))).

3
Calculate totals by ID

In a separate empty area, enter =IF(COUNTIFS(B2:B100,"Open",C2:C100,">="&F1,C2:C100,"<"&F1+1,A2:A100,"<>")=0,"No matching records",LET(m,(B2:B100="Open")*(C2:C100>=F1)*(C2:C100<F1+1)*(A2:A100<>""),i,FILTER(A2:A100,m),v,FILTER(D2:D100,m),u,UNIQUE(i),HSTACK(u,MAP(u,LAMBDA(x,SUM(FILTER(v,i=x))))))). The formula spills IDs and their totals into two columns.

4
Check duplicate handling

Compare the spilled totals with the matching source rows in columns A through D. If only one amount per ID should be included, adjust the formula to reflect the rule for selecting that amount.

Use Excel dynamic array formulas to count IDs and total amounts
Date and version requirements: The timestamp values must be real Excel dates and times. MAP and HSTACK may not be available in older Excel versions.
Work with records in WPS Spreadsheets

Count unique IDs and sum matching amounts in WPS Spreadsheets

Filter matching records, remove duplicate IDs from a separate list, and use SUMIFS to total their amounts in WPS Spreadsheets.

  1. 1. Prepare the worksheet: Open the workbook in WPS Spreadsheets. Use IDs in A2:A100, statuses in B2:B100, timestamps in C2:C100, amounts in D2:D100, and enter the target date without a time in F1.
  2. 2. Mark matching records: In an empty helper column, enter =AND(A2<>"",B2="Open",C2>=$F$1,C2<$F$1+1) on row 2 and fill it down. Replace "Open" with the required status.
  3. 3. Filter and copy IDs: Select the data range, choose Data > Filter, and filter the helper column to TRUE. Copy the visible IDs from column A into an empty column on a separate sheet or outside the filtered range.
  4. 4. Remove duplicate IDs: Select the copied IDs and choose Data > Remove Duplicates. Keep one occurrence of each ID; use =COUNTA(H2:H100) to count the resulting list if it is in H2:H100.
  5. 5. Sum amounts for each ID: If the unique IDs start in H2 on the original sheet, enter =SUMIFS($D$2:$D$100,$A$2:$A$100,H2,$B$2:$B$100,"Open",$C$2:$C$100,">="&$F$1,$C$2:$C$100,"<"&$F$1+1) in I2 and fill down. This adds all matching amounts for each ID.
Filter records by status and a full day's timestampsCount each matching ID once and sum its matching amountsOpen and save Microsoft Excel XLSX filesUse familiar spreadsheet filters and formulas
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't a timestamp match my date with an equals sign?

A timestamp includes a fractional time value, so it usually does not equal a date at midnight. Use a lower bound of >=F1 and an upper bound of <F1+1 when F1 contains a date without a time.

Do the totals include duplicate IDs?

Yes. The Excel and WPS examples list each ID once but add all amounts on rows that meet the status and date criteria. Use a different rule if only one amount per ID should count.

What happens if no records match?

The Excel unique-count formula returns 0, and the totals formula displays "No matching records." In WPS Spreadsheets, the helper-column filter will show no matching IDs.

Why does Excel not recognize MAP or HSTACK?

Your Excel version may not support those functions. Check for Office updates, or use the WPS Spreadsheets filter, Remove Duplicates, and SUMIFS approach instead.