Ryan Jacques
Ryan Jacques

Reputation: 49

Google Sheets Countunique in last n rows

I have a row of names of restaurants in Google Sheets, but I only want to countunique() the last n cells in the column without having to constantly update the range of the function manually. This is all being done on a pivot table as well.

E.g.:

n = 5

Raw Data

Pivot Table

Upvotes: 0

Views: 91

Answers (1)

player0
player0

Reputation: 1

try:

=QUERY(QUERY(A:A, 
 "offset "&COUNTA(A:A)-B1), 
 "select Col1,count(Col1) 
  where Col1 is not null 
  group by Col1
  label count(Col1)''")

0


or:

=ARRAYFORMULA(QUERY({UNIQUE(A:A), 
 IFNA(VLOOKUP(UNIQUE(A:A), QUERY(QUERY(A:A, 
 "offset "&COUNTA(A:A)-B1), 
 "select Col1,count(Col1) 
  where Col1 is not null 
  group by Col1
  label count(Col1)''"), 2, 0))*1}, 
 "where Col1 is not null"))

enter image description here

Upvotes: 1

Related Questions