Search code examples
filtergoogle-sheetsarray-formulasgoogle-sheets-querygs-vlookup

Showing the most, second most, and third most occurring values


Which formula shows unique (text) values of Column A, and the corresponding most occurring values (text) from Column B and sorts them on degree of appearance over different columns?

I already know how to show only the first most occurring values, but not the second, third and so on.

The formula which only shows the first most occurring values:

=ArrayFormula(VLOOKUP(UNIQUE(FILTER(A:A;A:A<>""));QUERY({A:B\A:A};"select Col1, Col2, count(Col3) where Col1 <> '' group by Col1, Col2 order by count(Col3) desc");{1\2};0))

Test Sheet


Solution

  • Try a combination of QUERY and INDEX pulled across

    =iferror(index(query($A$1:$C$100, "select B,count(C) where A contains '"&$E2&"' group by B order by count(C) desc",1) ,columns($AA:AB),1),"")
    

    where the media type is in E2.

    enter image description here