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
Thanks,
Best Answer
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'"))
transpose
to get the output to appear on a single row, andlabel count(A) 'Total'
to generate an appropriate label for the row.query(A3:B46,"SELECT A, count(A) GROUP BY A PIVOT B")
PIVOT
clause.Example output