Search code examples
google-sheetsgoogle-sheets-formula

How to find the most frequent word in column B for a value in column A in Google Sheets


I have a spreadsheet that has a session value in column A with the name of a person that performed a task in column B. I would like to create a formula that will analyze the names in column B and determine who performed the most tasks for each session in column A.

enter image description here

For this example, I would like the results in column C to return the value "Will" for the rows 2 through 6, as Will performed the most actions for Session 5726.

I have tried using the MODE function, but I believe that only returns numeric values, rather than text values.


Solution

  • I think the most optimus way to not make multiple calculations is to create a Query in an auxiliary column:

    =QUERY(A:B,"Select A,B,Count(B) group by A,B order by Count(B) desc")
    

    enter image description here

    Then with VLOOKUP you'll be able to find the first value of that session (which means the max because it is ordered by the count of B):

    =INDEX(IFNA(VLOOKUP(A:A,D:E,2,0)))
    

    enter image description here