How to Rank Values and Count Items in the Top Five in Excel
Question details
Identify the top five distinct values from a large dataset, count their frequency, and apply conditional formatting to highlight them.

- Product
- Spreadsheets
- Device & OS
- not provided
- Scenario
- Analyzing a dataset with many repeated numeric values to extract the most frequent or highest distinct numbers.
- Observed behavior
- Users need a reliable formula or method to extract the top five unique values, count them, and highlight them, but often encounter zero returns when using array formulas improperly.
Ensure that your source data contains actual numeric values, not numbers formatted as text, and remove any completely blank cells in your data range before applying formulas.
Extract Distinct Values, Count Frequencies, and Format Cells
Use a combination of array formulas to find unique top values, count them with COUNTIF, and highlight the results.
In newer versions of spreadsheet software, dynamic arrays automatically handle multi-cell outputs. In older versions, you must use legacy array formulas by pressing Ctrl+Shift+Enter, which encloses the formula in curly braces {}.
In an empty column (e.g., cell B1), enter your formula to extract the highest unique values. If using modern dynamic arrays, a combination of UNIQUE and LARGE works best. For older versions, use an array formula like =MODE(IF(1-ISNUMBER(MATCH($A$1:$A$1000,$B$1:B1,0)),$A$1:$A$1000)) and press Ctrl+Shift+Enter.
In the adjacent column (e.g., cell C1), enter the formula =COUNTIF($A$1:$A$1000, B1). Drag the fill handle down to calculate the frequency of each of your extracted top five values.
Select your original data in column A. Navigate to the 'Home' tab, click 'Conditional Formatting', choose 'Highlight Cells Rules', and set it to highlight cells equal to the values you extracted in column B.

Rank and Count Top Values Effectively with WPS Spreadsheet
WPS Spreadsheet provides comprehensive support for both standard and dynamic array formulas, making it simple to analyze large datasets. You can seamlessly extract distinct values, count frequencies, and highlight data without compatibility issues.
- 1. Import Your Data: Open your worksheet containing the repeated values in WPS Spreadsheet.
- 2. Extract Top 5 Distinct Values: Click on an empty cell in a new column and enter your array or UNIQUE formula. Press Enter (or Ctrl+Shift+Enter for legacy arrays) to display the top unique items.
- 3. Calculate Frequency: In the adjacent column, type =COUNTIF(A:A, B1) and drag the fill handle down to calculate exactly how many times each distinct value appears.
- 4. Highlight Your Data: Select the original data column, go to Home > Conditional Formatting, and create a rule to format cells that match your top five distinct values.

Frequently Asked Questions
Why do my array formulas show zeros instead of the actual top values?
This usually occurs if your original data is formatted as text rather than numbers, or if there are completely blank cells within your selected range. Additionally, check that you used Ctrl+Shift+Enter to execute the formula if you are on an older spreadsheet version.
Can I use the top/bottom rules in conditional formatting directly?
You can use the built-in 'Top 10 Items' rule under Conditional Formatting and change the value to 5. However, this will highlight the top 5 absolute highest cells, which might just be 5 copies of the exact same number, rather than the top 5 distinct (unique) values.
Do I need to re-enter Ctrl+Shift+Enter every time I edit the formula?
Yes, if you are using legacy array formulas, any modification to the formula requires you to finalize it by pressing Ctrl+Shift+Enter again. If you just press Enter, the formula will break and return an error or an incorrect result.
How do I remove duplicate values before ranking?
Instead of manual removal, modern formulas like UNIQUE automatically filter out duplicates in memory. This allows you to wrap it with the LARGE function to instantly find the top distinct values without altering your original dataset.




