Home > other >  Remove multiple column labels from Google Sheets Query
Remove multiple column labels from Google Sheets Query

Time:12-16

Trying to remove the column labels from a query and I've tried the following two ways but still getting error. What's the best way to do this?

=QUERY('Form Responses 1'!2:115, "SELECT C, label(AVG(D),''), label(AVG(E),''), label(AVG(F),''), label(AVG(G),''), label(AVG(H),''), label(AVG(I),''), label(AVG(J),''), label(AVG(K),''), label(AVG(L),'') WHERE C IS NOT NULL GROUP BY C ORDER BY C", 0)

=QUERY('Form Responses 1'!2:115,"SELECT C,AVG(D),AVG(E),AVG(F),AVG(G),AVG(H),AVG(I),AVG(J),AVG(K),AVG(L) WHERE C IS NOT NULL GROUP BY C ORDER BY C label(D),label(E),label(F),label(G),label(H),label(I),label(J),label(K),label(L) ",0)

CodePudding user response:

You just have to write label once, followed by the columns you want to label and the label you want to give them.

=QUERY(data,"... label A '', B '', C''...")

CodePudding user response:

The QUERY function has a specific syntax that you need to follow in order to use it correctly. In particular, the label function must be applied to the entire column reference, not to each column individually.

Here is the correct syntax for the first QUERY function you provided:

Copy code

=QUERY('Form Responses 1'!2:115, "SELECT C, label(AVG(D),''), label(AVG(E),''), label(AVG(F),''), label(AVG(G),''), label(AVG(H),''), label(AVG(I),''), label(AVG(J),''), label(AVG(K),''), label(AVG(L),'') WHERE C IS NOT NULL GROUP BY C ORDER BY C", 0)

And here is the correct syntax for the second QUERY function you provided:

Copy code

=QUERY('Form Responses 1'!2:115,"SELECT C,AVG(D),AVG(E),AVG(F),AVG(G),AVG(H),AVG(I),AVG(J),AVG(K),AVG(L) WHERE C IS NOT NULL GROUP BY C ORDER BY C label(D,E,F,G,H,I,J,K,L) ",0)

I hope this helps! Let me know if you have any further questions or if you need more clarification.

  • Related