heeul
heeul

Reputation: 7

How can I count unique values and groupby?

I have been trying to count and group per row the number of unique values. Perhaps will be easier to explain showing a table. I should first transpose before counting and groupby??

Box1 Box2 Box3 Count Result 1 Count Result 2 Count Result 3
Data A Data A Data B Data A = 2 Data B = 1
Data C Data D Data B Data C = 1 Data D = 1 Data B = 1

Upvotes: 0

Views: 198

Answers (1)

player0
player0

Reputation: 1

in GS try:

=ARRAYFORMULA(TRIM(SPLIT(FLATTEN(QUERY(QUERY(
 QUERY(SPLIT(FLATTEN(A2:C3&" = ×"&ROW(A2:C3)), "×"), 
 "select max(Col1) group by Col1 pivot Col2")&
 QUERY(SPLIT(FLATTEN(A2:C3&" = ×"&ROW(A2:C3)), "×"), 
 "select count(Col1) group by Col1 pivot Col2")&"​", 
 "offset 1", ),,9^9)), "​")))

enter image description here

Upvotes: 1

Related Questions