Search code examples
google-sheetsgoogle-query-language

count the number of yes and no for month & category in Google Sheet


I want help in re-displaying the data ( count the number of yes and no for month and category ) on Sheet 2 by code (automatically)

Example:

https://docs.google.com/spreadsheets/d/14idoHEq1S__TJkpa07R86mCLhKx5i-FMcO5ZQZ8PWOo/edit?usp=sharing

Sheet1

enter image description here

To Sheet 2

enter image description here


Solution

  • use:

    =ARRAYFORMULA(QUERY(SPLIT(FLATTEN(IF('Sheet 1'!B2:F="",,
     MONTH('Sheet 1'!A2:A)&TEXT('Sheet 1'!A2:A, "mmmm")&"♦"&
     'Sheet 1'!B1:F1&"♦"&'Sheet 1'!B2:F&"♦"&'Sheet 1'!B2:F)), "♦"), 
     "select Col1,Col2,count(Col3)
      where Col1 is not null 
      group by Col1,Col2
      pivot Col4
      label Col1'Month',Col2'ZONE' 
      format Col1'mmmm'"))
    

    enter image description here