Assign Sequence Numbers by Employee and Date in Excel
Question details
Create a sequence number for each employee’s records based on date, with the newest record numbered 1.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Employee IDs are stored in column A and record dates are stored in column C. The user needs a per-employee ranking or sequence in another column.
- Observed behavior
- The desired result is for newer dates within the same employee ID to receive lower sequence numbers, while older dates receive progressively larger numbers.
Make sure the date column contains real Excel dates rather than text values. Decide how tied dates should be handled, because identical dates receive the same result with the basic formula.
Use COUNTIFS to rank each employee's records by newest date
Use this formula when employee IDs are in column A, dates are in column C, and you want the newest date for each employee to be sequence number 1.
COUNTIFS counts records for the same employee whose dates are greater than or equal to the current row's date. That count becomes the descending date sequence number.
Select the first result cell, such as D2, and enter a header such as Sequence Number in D1.
In D2, enter =COUNTIFS($A$2:$A$1000,$A2,$C$2:$C$1000,">="&$C2). Update 1000 to match or exceed the last row of your data.
Press Enter, then drag the fill handle from D2 down the column or double-click the fill handle to copy the formula to the remaining records.
Filter or sort by an employee ID in column A and confirm that the most recent date in column C has sequence number 1.

Use a unique record ID to break ties on matching dates
Use this approach when each employee record must have a unique sequence number even when two or more records share the same date.
Rank employee records by date with COUNTIFS in WPS Spreadsheet
WPS Spreadsheet supports COUNTIFS formulas for assigning a descending sequence to each employee’s dated records. Enter the formula once, fill it down, and review the newest-to-oldest numbering directly in your worksheet.
- 1. Open the employee worksheet: Open your .xlsx or .xls file in WPS Spreadsheet and identify the employee ID, date, and output columns.
- 2. Enter the ranking formula: Click the first output cell, such as D2, and enter =COUNTIFS($A$2:$A$1000,$A2,$C$2:$C$1000,">="&$C2).
- 3. Fill the formula down: Press Enter and drag or double-click the cell fill handle to apply the formula to each employee record.
- 4. Review results by employee: Use Data > Filter or sort the employee ID and date columns to confirm that the latest date is numbered 1 for each employee.

Frequently Asked Questions
Why does the newest date receive sequence number 1?
The formula counts rows for the same employee with dates greater than or equal to the current date. A newest date has only itself at or above that date, so the count is 1.
Can I use this formula when my employee IDs and dates are in different columns?
Yes. Replace the A ranges with your employee ID column and replace the C ranges with your date column. Keep the ranges the same size and lock them with $ signs.
What happens when two records for one employee have the same date?
The basic COUNTIFS formula gives both records the same number because both dates meet the same condition. Add a unique record ID column and use it as a tie-breaker when every row needs a distinct sequence.
How do I extend the formula beyond row 1000?
Change every 1000 reference in the formula to a row number that covers your data, such as $A$2:$A$5000 and $C$2:$C$5000. You can also use an Excel Table so formulas expand with new rows.
Does this formula require the data to be sorted by date first?
No. COUNTIFS evaluates the employee ID and date values in the ranges, so the ranking works even if the source records are not sorted. Sorting can still make the results easier to review.




