1

In this google sheet I have an array of Types and floors, The criteria rows and headers are auto populated by unique formulas.

I'm trying to create an array formula which will expand in the width (columns) and height (rows) infinitely, to lookup the count.

So instead of having an arrayformula in each cell in row 3, there will be just one in F3

enter image description here

Thanks,

1

1 Answer 1

1

Try this query:

={Transpose(query(A3:B46,"SELECT count(A) GROUP BY B label count(A) 'Total'"));query(A3:B46,"SELECT A, count(A) GROUP BY A PIVOT B")}


The formula consists of two queries:

  • Transpose(query(A3:B46,"SELECT count(A) GROUP BY B label count(A) 'Total'"))
    • this counts the number of "Floor" items for each "Type".
    • Note inclusion of transpose to get the output to appear on a single row, and label count(A) 'Total' to generate an appropriate label for the row.
  • query(A3:B46,"SELECT A, count(A) GROUP BY A PIVOT B")
    • this uses the PIVOT clause.

Example output

Screenshot

1
  • This is a great solution. Oct 2, 2020 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.