Search code examples
google-sheetssplitgoogle-sheets-formulaflattentextjoin

How to count values if option checked is selected in one cell


I have a spreadsheet where users fill out a form, they have multiple options they can pick by clicking the checkboxes.

The responses sheets looks like this

enter image description here

I want to filter the results by option, so my main goal is to get the total amount of options selected: enter image description here

I've been trying with COUNTIF but it's not working because I'm not selecting the specific response

=COUNTIF('Form Responses 1'!C2:F4,"*"&$B$1&"*")

I'm assuming I need to add a VLOOKUP but I'm not sure how to match it with the option

Here's a spreadsheet to play around with it


Solution

  • try:

    =INDEX({QUERY(TRIM(SPLIT(FLATTEN(A2:A&"×"&SPLIT(B2:B, ",")), "×")), 
     "select Col1,count(Col1) where Col2 is not null group by Col1 pivot Col2 label Col1 'Person'"); 
     {"Total", TRANSPOSE(MMULT(TRANSPOSE(QUERY(QUERY(TRIM(SPLIT(FLATTEN(A2:A&"×"&SPLIT(B2:B, ",")), "×")), 
     "select count(Col1) where Col2 is not null group by Col1 pivot Col2"), "offset 1", )*1), 
     SEQUENCE(COUNTUNIQUE(TRIM(FLATTEN(SPLIT(TEXTJOIN(",", 1, B2:B), ",")))), 1, 1, )))}})
    

    enter image description here