Count unique combinations of two columns
=ROWS(UNIQUE(A2:B13))Excel · result on the sample sheet: 10
Describe what you need and get a working ROWS formula for Excel and Google Sheets, tested on real data before you copy it. ROWS counts how many rows a range or array has, whether or not the cells contain anything.
Each formula below was calculated on its own sample sheet. Open one to see the sheet, why it works, and to try it yourself.
=ROWS(UNIQUE(A2:B13))Excel · result on the sample sheet: 10
=(B6/B2)^(1/(A6-A2))-1Excel · result on the sample sheet: 11.62%
=COUNTIF(B2:B13,"Yes")/COUNTA(B2:B13)Excel · result on the sample sheet: 70.0%
=SUMPRODUCT(--(C2:C11<=B2:B11))/ROWS(B2:B11)Excel · result on the sample sheet: 70%
=AVERAGE(B2:B7)Excel · result on the sample sheet: 69.80
=SORTBY(A2:A9,SEQUENCE(ROWS(A2:A9)),-1)Excel · result on the sample sheet: 8 rows (C2:C9)
=FILTER(A2:B13,MOD(SEQUENCE(ROWS(A2:A13)),E1)=0)Excel · result on the sample sheet: 4 rows (D3:E6)
=INDEX(A2:A7,MOD(MATCH(D1,A2:A7,0),ROWS(A2:A7))+1)Excel · result on the sample sheet: Tom
You describe the task in plain English, and it writes the formula, using ROWS where that's the right tool, for your table or a sample one. The formula is run in our engine in Excel and Google Sheets mode before you see it, so you get its result, not just a guess.
ROWS counts how many rows a range or array has, whether or not the cells contain anything.
Yes. Each example below opens a page where you try the formula in a live grid and it's checked as you go, and the ROWS function page has a practice exercise.