Function Problems

How to Assign Sequential Numbers to Rows with Matching Dates in Excel

Jason MillerJason Miller Nov 11, 2026 868 views

Question details

The user needs a method to automatically assign the same sequential number or rank to rows that share the same date, ordered chronologically.

How to Assign Sequential Numbers to Rows with Matching Dates
Product
Excel
Device & OS
not provided
Scenario
Organizing datasets where rows with matching dates require identical sequential IDs, from earliest to latest.
Observed behavior
The goal is to ensure the earliest date receives 1, the next chronological date receives 2, and identical dates share the exact same assigned value.
Before you start

Ensure your date column contains valid date values rather than text strings so that formulas and Power Query can evaluate and sort them chronologically.

Solution 1Recommended

Use the XMATCH and UNIQUE Dynamic Array Formula

A straightforward dynamic array formula that ranks dates chronologically, assigning identical ranks to duplicate dates.

This formula extracts unique dates, sorts them chronologically, and then finds the match index for each date in your main list. For advanced performance on larger datasets (up to 5,000 rows), the LET function can be combined to avoid recalculation.

1
Select the target cell

Click on the first cell in an empty adjacent column where you want the sequential numbers to appear.

2
Enter the formula

Type `=XMATCH(A:A, SORT(UNIQUE(A:A)))` (replace A:A with your actual date range, such as A2:A100).

3
Apply the formula

Press Enter. The dynamic array formula will automatically spill down the column, assigning accurate sequential numbers to your dates.

Use the XMATCH and UNIQUE Dynamic Array Formula
Offset Adjustment: If you want the numbering to start at a different value instead of 1, simply add your desired offset to the end of the formula, like `=XMATCH(A2:A100, SORT(UNIQUE(A2:A100)))+99` to start at 100.
Efficient Spreadsheet Solution

Assign Sequential Numbers Easily with WPS Spreadsheet

WPS Spreadsheet provides robust support for advanced formulas and large dataset management. You can quickly assign identical sequence numbers to matching dates completely free.

  1. 1. Open your file in WPS Spreadsheet: Launch WPS Office and open the workbook containing your date records.
  2. 2. Sort and apply a standard formula: Sort your data by the date column chronologically. In cell B2 (assuming dates are in A), type `=IF(A2=A1, B1, B1+1)` where B1 is set to 1.
  3. 3. Drag to fill: Double-click the fill handle in the bottom-right corner of cell B2 to apply the sequence calculation to the rest of your data.
Fully compatible with Microsoft Excel formulas, arrays, and formatting.Handles large datasets efficiently without performance lagging.Free to use with a familiar, easy-to-navigate interface.
microsoft office alternative - wps office

Frequently Asked Questions

What if my dates are completely out of order?

The SORT and UNIQUE formula combination automatically handles unsorted dates by determining the chronological order internally before assigning the rank, so your source data does not need to be manually sorted.

Why use the LET function instead of just XMATCH?

The LET function optimizes performance in large datasets. It defines variables (like the unique sorted date list) once in memory rather than recalculating the entire array for every single row, preventing the spreadsheet from slowing down.

Can I output my Power Query results to a different worksheet?

Yes. When you choose 'Close & Load To...' in Power Query, you can select 'Existing Worksheet' and pick a specific cell on another sheet, or choose 'New Worksheet' to keep your result table separate from your input data.