How to Rank Within a Group in Excel (3 Methods)

How to Rank Within a Group in Excel (3 Methods)

Dataset Overview

Suppose we have a dataset containing information about various types of products and electronic accessories. The data includes their Category (in column C) and Quantity (in column D). Our goal is to rank these items within their respective Category and Quantity, using a new column (E).

excel rank within group


Method 1 – Using the SUMPRODUCT Function

  • Start by selecting cell E5, where we want to rank the products and electronic accessories.

Apply the SUMPRODUCT Function to Rank Within Group in Excel

  • In the Formula Bar, enter the following SUMPRODUCT function:
=SUMPRODUCT((C5=C$5:C$15)*(D5<D$5:D$15))+1

Here,

  • (C5=C$5:C$15) checks if the product category matches.
  • (D5<D$5:D$15) verifies if the quantity (D5) is less than any value in the range D$5:D$15.
  • The +1 ensures the ranking starts from 1.

Apply the SUMPRODUCT Function to Rank Within Group in Excel

  • Press Enter to get the result (e.g., 4).

  • Drag the Fill Handle downward to rank other items within the group.


Method 2 – Using the COUNTIFS Function

  • Select an empty cell (e.g., E5) for the COUNTIFS function.

Perform the COUNTIFS Function to Rank Within Group in Excel

  • Enter the following formula in the Formula Bar:
=COUNTIFS(C$5:C$15,C5,D$5:D$15, ">"&D5)+1

Here,

  • C$5:C$15 is the criteria range for product category.
  • C5 is the specific product category.
  • D$5:D$15 is the criteria range for quantity.
  • “>”&D5 checks for quantities greater than the value in cell D5.

Perform the COUNTIFS Function to Rank Within Group in Excel

  • Press Enter to get the result (e.g., 4).

  • Autofill the formula to rank other items.

Perform the COUNTIFS Function to Rank Within Group in Excel

Read More: Ranking Based on Multiple Criteria in Excel


Method 3 – Using the SUM Function (Array Formula)

  • Select cell E5.

Use the SUM Formula to Rank Within Group in Excel

  • Enter the following formula in the Formula Bar:
=SUM((C5=$C$5:$C$15)*(D5<$D$5:$D$15))+1

Here,

  • (C5=$C$5:$C$15) matches the product category.
  • (D5<$D$5:$D$15) compares the quantity with values in the range D$5:D$15.

Use the SUM Formula to Rank Within Group in Excel

  • Press Enter to get the result (e.g., 4).

  • Autofill the SUM function to rank other items.

Use the SUM Formula to Rank Within Group in Excel

Read More: Excel Formula to Rank with Duplicates


Things to Remember

If the SUMPRODUCT function doesn’t find a number in the reference cell, it returns an #N/A error. Double-check your data to avoid this issue.


Download Practice Workbook

You can download the practice workbook from here:


Related Articles


<< Go Back to Excel RANK Function | Excel Functions | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Md. Abdur Rahim Rasel
Md. Abdur Rahim Rasel

MD. ABDUR RAHIM is a marine engineer proficient in Excel and passionate about programming with VBA. He views programming as an efficient means to save time while managing data, handling files, and engaging with the internet. His interests extend to Rhino3D, Maxsurf C++, AutoCAD, Deep Neural Networks, and Machine Learning, reflecting his versatile skill set. He earned a B.Sc in Naval Architecture & Marine Engineering from BUET, and now he has become a content developer, creating technical content... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo