I have a query that queries over a set of rows. I want to run this query, itself, for each row in another set of rows. The one value that changes in the query for each row is something in the where clause. I am trying to wrap the query in an arrayformula so that I only have to put the formula in the top cell and it will auto-populate, but it will not 'auto-populate'. How do I do this?

Example is here.



Place this formula in the top cell (i.e., header cell) of any otherwise empty column:


QUERY is not necessary, as you can see.

You can change the "Header" text to whatever you like.

Another option would be to place the following formula in the top left cell of any two otherwise empty columns:

=ArrayFormula(QUERY({A2:A},"Select Col1, COUNT(Col1) WHERE Col1 Is Not Null GROUP BY Col1 LABEL Col1 'Categories', COUNT(Col1) 'Header 2'"))

This formula would produce the "Categories" list and the count of each unique category (i.e., a two-column array).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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