Search code examples
google-sheetsgoogle-sheets-formulaarray-formulasgoogle-sheets-querygoogle-query-language

How to skip a column when using array formula to generate content in Google Sheets?


I recently came across this spreadsheet in another question and made a copy. Here it is:

https://docs.google.com/spreadsheets/d/14pCL0x-hlFyzWoW6-F8H33C6gJuYBv-p3NsjSvA5A0I/edit?usp=sharing

What I want to do is skip column B using the array formula. So column B would be completely empty, column C will contain the totals, D unique, and E the other unique. Is it possible to do using array formula in Google Sheets?


Solution

  • sure, why not:

    =ARRAYFORMULA(QUERY({F3:H, 
     IF((G3:G<>"")*(COUNTIFS(F3:F&G3:G, F3:F&G3:G, ROW(G3:G), "<="&ROW(G3:G))=1), F3:F&G3:G, ),
     IF((H3:H<>"")*(COUNTIFS(F3:F&H3:H, F3:F&H3:H, ROW(H3:H), "<="&ROW(H3:H))=1), F3:F&H3:H, )},
     "select Col1,' ',count(Col1),count(Col4),count(Col5) 
      where Col1 !='' 
      group by Col1 
      order by count(Col1) desc 
      label count(Col1)'Total',
            count(Col4)'Unique (for id)',
            count(Col5)'Unique (for name)',
            ' '''", 1))
    

    0

    spreadsheet demo