FormulaCraft

How to find the top N per group with formulas in Excel and Google Sheets

Topic:Pivot-style summaries (formula approach)
Excel & Google Sheets
=LARGE(IF(A2:A7="East",B2:B7),1)

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. 1Place group labels in A2:A7 and numeric values in B2:B7.
  2. 2To get the single largest value for 'East', enter as an array formula: =LARGE(IF(A2:A7="East",B2:B7),1). In Excel 365 this spills automatically; in older Excel press Ctrl+Shift+Enter.
  3. 3Change the last argument from 1 to 2 for second-largest, 3 for third-largest, and so on.
  4. 4For multiple groups, use FILTER to isolate each group's rows first: =LARGE(FILTER(B2:B7,A2:A7="East"),1).
  5. 5To return the full top-N rows (with all columns), use =FILTER(A2:B7,RANK(B2:B7,B2:B7,0)<=2) — adjust 2 to your N.

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

How do I get the top N rows with all their columns, not just the value?

Use =FILTER(A2:B7,(A2:A7="East")*RANK(B2:B7,B2:B7)<=2) — but RANK doesn't handle group isolation natively, so it is cleaner to pre-filter with FILTER then wrap in SORT and INDEX.

What if there are ties at position N?

LARGE returns the Nth largest value regardless of ties. Both tied values would be included if you filter on value >= LARGE(...,N).

Can I get top N per group for multiple groups at once?

In Excel 365, BYROW and MAKEARRAY can automate this. In Google Sheets, QUERY with ORDER BY and LIMIT is often the cleanest approach.

More on Pivot-style summaries (formula approach)

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: