FormulaCraft

How to rank values within each group in Excel and Google Sheets

Topic:RANK & statistical aggregates
Excel & Google Sheets
=COUNTIFS($A$2:$A$6,A2,$B$2:$B$6,">"&B2)+1

Verified example

Computed by a real spreadsheet engine on the sample data below.

RegionSalesRank In Region
North320
South410
North290
South380
North450

=COUNTIFS($A$2:$A$6,A2,$B$2:$B$6,">"&B2)+12

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1Set up columns: Group (A), Value (B), Rank Within Group (C).
  2. 2In C2, enter =COUNTIFS($A$2:$A$6,A2,$B$2:$B$6,">"&B2)+1.
  3. 3COUNTIFS counts how many rows share the same group and have a higher value; adding 1 converts that count to a rank.
  4. 4Copy the formula down for all rows — each row gets ranked among its group peers.

Tips

Need it for your exact data?

Describe your columns in plain English and get the precise formula for your sheet, with the right Excel or Sheets syntax.

Frequently asked

Does this handle ties correctly?

Tied values receive the same rank (like RANK with the default tie behaviour), and the next rank is skipped.

Can I use this for text groups and numeric scores?

Yes. Column A can be any group label (text or number) and column B should be the numeric values to rank.

More on RANK & statistical aggregates

See all →

Formulas used

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: