Google SpreadSheet Query: Can I remove column header?

146k views Asked by At

I'm doing this query at my google spreadsheet:

=QUERY(H4:L35;"select sum(L) where H='First Week'"; -1)

But it returns a little table with "sum" as header and result below it. What I want is just the result! How I remove header? Can I?

9

There are 9 answers

9
KRR On BEST ANSWER

Try this:

=QUERY(H4:L35,"select sum(L) where H='First Week' label sum(L) ''")
2
Steven M. Mortimer On

Instead of labeling column names as blanks using '', you can omit all headers like this:

=QUERY(H4:L35,"select sum(L) where H='First Week'", 0)

0
DeeKay789 On

... or this

=QUERY(QUERY(H4:L35;"select sum(L) where H='First Week'"),"OFFSET 1",0)

This is more concise when ALL label classes are not wanted.

Note that 'select' and 'where' classes are not required in the second QUERY statement.

1
Dean Falconer On
=INDEX(QUERY(H4:L35;"select sum(L) where H='First Week'"; -1),2,1)

This just parses the returned array and selects the 2nd record returned in the first column.

You can also do this with the filter function which is less compute intensive.

=SUM(FILTER(L4:L35, H4:H35 = "First Week"))
0
Oscar Manrique On

For queries using pivot, try using INDEX to remove headers from the pivoted columns.

=INDEX(QUERY('Class hours'!A2:C11,
             "select sum(C) 
              where A = '"&A5&"' 
              group by A 
              pivot B"), 2)

Got the answer from this thread: https://stackoverflow.com/a/63468791/5424088

0
andyJK On
=QUERY(H4:L35;"select sum(L) where H='First Week'"; -1)

Just make a SUM of the QUERY result - like this:

=SUM(QUERY(H4:L35;"select L where H='First Week'"))

With this solution, you can also calculate with the cells and then add everything up.

=SUM(QUERY(H4:L35;"select L*(S-R) where H='First Week'"))
1
Andy On

See the format here.

Example:

=QUERY(B4:C38,
   "SELECT C, sum(B) where C!='' group by C label C 'Member', sum(B) 'Sum'"
)
9
user280150 On

=QUERY(QUERY(A1:D, "SELECT *", 1), "SELECT * OFFSET 1", 0)

The outer query: "SELECT * OFFSET 1" excludes the first row (the header).

The inner query explicitly specifies one row of headers (via the third argument supplied to QUERY), whilst the outer query specifies none.

0
Brian Wochele On

I have a QUERY which is returning the top 3. I could not get this to work when returning multiple rows. I ended up just hiding the row with the formula and only the answers show now.