How to Rank Values Within Groups in Excel (Without RANK.EQ and FILTER)
Question details
The user needs to rank sales values separately for each retail outlet group, but the standard RANK.EQ function fails when combined with a FILTER array.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Ranking specific categorized data, such as sales figures per retail outlet, without triggering formula errors from incompatible functions.
- Observed behavior
- RANK.EQ expects a range reference and returns an error when a FILTER expression (which returns an array) is used as its second argument.
Ensure your data is organized in columns with clear headers for both the categories (e.g., Retail Outlet) and the numerical values you want to rank (e.g., Sales).
Use the COUNTIFS Function to Rank Within Groups
This method bypasses the limitations of RANK.EQ by counting how many values within the same group are strictly greater than the current value, and then adding 1 to establish the rank.
Because the RANK.EQ function strictly requires a range reference instead of an array in its second argument, combining it directly with the FILTER function will result in a formula error. Fortunately, the COUNTIFS function handles multiple conditions dynamically and serves as an excellent workaround for conditional grouping and ranking.
Click on the cell where you want the rank number to appear for the first row of your data (for example, cell D3).
Type the formula: =COUNTIFS(A$3:A$2007, A3, C$3:C$2007, ">"&C3)+1 into the formula bar. In this example, column A represents the retailer group and column C represents the sales value.
Press Enter to calculate the rank for the first entry. The result will show its relative rank within its specific retailer group.
Click and drag the fill handle (the small square at the bottom-right corner of the cell) down to apply the formula to the rest of the column.

Calculate Complex Formulas Easily in WPS Spreadsheet
WPS Spreadsheet fully supports advanced logical functions like COUNTIFS, RANK.EQ, and FILTER. It offers a smooth and lightweight experience for organizing, grouping, and analyzing complex data structures.
- 1. Open your data in WPS Spreadsheet: Launch WPS Spreadsheet and open your existing .xlsx file containing the grouped data.
- 2. Prepare a ranking column: Create a new column header named 'Rank' next to your values column.
- 3. Input the COUNTIFS logic: Enter the COUNTIFS formula tailored to your group and value columns (e.g., =COUNTIFS(A$3:A$2007, A3, C$3:C$2007, ">"&C3)+1).
- 4. Drag to fill: Press Enter and double-click the fill handle to automatically rank all categories instantly.

Frequently Asked Questions
Why does the RANK.EQ function not work with the FILTER function?
The RANK.EQ function strictly requires a direct range reference (such as A1:A10) for its second argument. The FILTER function outputs a dynamic array in memory rather than a direct reference, causing an error when nested inside RANK.EQ.
Will the COUNTIFS method work if my data is not sorted?
Yes. The COUNTIFS formula dynamically evaluates the entire specified range. Your data does not need to be sorted by group or by value beforehand for the formula to return the correct rankings.
How can I reverse the rank to ascending order?
To rank values from smallest to largest within a group, simply change the greater-than operator (">") in the COUNTIFS formula to a less-than operator ("<"). For example: =COUNTIFS(A$3:A$2007, A3, C$3:C$2007, "<"&C3)+1.
How does this workaround handle blank or zero values?
The COUNTIFS function will treat zero values as standard numerical entries and rank them accordingly. If there are blank cells in the value column, they may be treated as zeros; it is recommended to clean your data or add an IF statement to leave the cell blank if the value is empty.




