Assign Sequential Ranks by Multiple Criteria in Excel
Question details
Assign an incrementing rank to records with matching Part, Oper, and Date values, starting each group at 1.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains records that need to be numbered within each combination of Part, Oper, and Date, potentially without sorting the data.
- Observed behavior
- Each matching group should receive ranks 1, 2, 3, and so on in worksheet order, even when its records are not adjacent.
Identify the columns containing Part, Oper, and Date and choose an empty column for the ranks. The examples assume headers in row 1, Part in column A, Oper in column C, Date in column D, and ranks in column E; adjust the references if your layout differs.
Use COUNTIFS to rank matching records without sorting
Use this method when matching records are scattered or sorting could affect other formulas.
COUNTIFS counts matching records from the first data row through the current row, so each group is numbered in its existing worksheet order.
In cell E2, enter =COUNTIFS(A$2:A2,A2,C$2:C2,C2,D$2:D2,D2).
Select E2 and drag the fill handle down column E through the last data row. Each combination of Part, Oper, and Date starts at 1 and increments on later matches.

Rank adjacent groups after sorting the data
Use this shorter formula when you can safely sort records so that each group is contiguous.
Create Sequential Group Ranks in WPS Spreadsheets
Use COUNTIFS in WPS Spreadsheets to number records within each Part, Oper, and Date group without rearranging the worksheet.
- 1. Open the spreadsheet: Open WPS Spreadsheets and use Open to select your workbook.
- 2. Enter the formula: With Part in column A, Oper in C, and Date in D, enter =COUNTIFS(A$2:A2,A2,C$2:C2,C2,D$2:D2,D2) in E2.
- 3. Fill the rank column: Select E2 and drag its fill handle down to the last record. Adjust the column references if your data uses a different layout.
- 4. Save the workbook: Use File > Save As to save the completed spreadsheet in XLSX format.

Frequently Asked Questions
Can I rank matching records without sorting them?
Yes. Enter =COUNTIFS(A$2:A2,A2,C$2:C2,C2,D$2:D2,D2) in E2 and fill it down. The formula counts each group in its existing row order.
Why do two dates that look the same get separate ranks?
The cells may contain different time values even if their formatting shows only the date. Use date-only values or a helper column, then point the COUNTIFS date ranges and criteria to that column.
Will the ranks change if I reorder the rows?
Yes. The COUNTIFS formula numbers matches according to their current worksheet order. Reordering records can change which record receives each rank.
What if my grouping fields are in different columns?
Replace the A, C, and D references in both the COUNTIFS ranges and their corresponding criteria with the columns containing your Part, Oper, and Date values.




