I am trying to create a simple query in my Google Sheet that will allow me to label the two columns it is outputting and sort the results based off of another column. However as soon as I add the Order By or the second Label command it throws and error. Here is my formula. Thanks for any help.
=query(A1:H,"SELECT H, SUM(G) WHERE H > '' AND G > 0 GROUP BY H ORDER BY A LABEL SUM(G) 'Sub Total', LABEL H 'Group Description'",0)
You can use the label clause in a Google Sheets query to create specific labels for the results of certain columns. In this example, we select all columns in the range A1:C13 and we label column A as 'Column A' in the resulting output.
When you want to concatenate two columns use the ArrayFormula with Concat as below. Actually, the function CONCAT in Google Sheets is 'equal' to the Ampersand sign usage.
Try this. You can hide the query return of column A if you need to. Also note the label syntax.
=query(A2:H,"SELECT A,H, sum(G) where H is not null and G>0 group by A,H order by A asc label sum(G) 'Sub Total', H 'Group Description',A 'Col A'",1)
Here is my test spreadsheet:https://docs.google.com/spreadsheets/d/1U6OFD_bxkNu27WMFPYHcxps1SA3oH9m3jMTEdb-fiQY/edit?usp=sharing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With