Home > other >  Label Column with Query that references multiple sheets in Google Sheets
Label Column with Query that references multiple sheets in Google Sheets

Time:11-23

using the below script to "append" data from multiple sheets on to one and it works but I need for it to add the sheet name where the data comes from in Column 28 and when I add label Col28 'sheet name' to the end of the SQL syntax, it triggers an error and will not display.

Please advise

=ARRAYFORMULA(QUERY({'Pain Management MASTER'!A1:AA;Billing!A2:AA;Collections!A2:AA;Dropped!A2:AA}, "Select * Where Col1 is not null label Col28 'sheet name", 1))

Ultimately, I expected the query to append the sheets, ignore blank rows and add the sheet name to Column 28.

CodePudding user response:

you are missing the ending single quote... try:

=ARRAYFORMULA(QUERY({
 'Pain Management MASTER'!A1:AA, IFERROR('Pain Management MASTER'!A1:A/0, "Pain Management MASTER");
 Billing!A2:AA, IFERROR(Billing!A2:A/0, "Billing");
 Collections!A2:AA, IFERROR(Collections!A2:A/0, "Collections");
 Dropped!A2:AA, IFERROR(Dropped!A2:A/0, "Dropped")}, 
 "where Col1 is not null label Col28 'sheet name'", 1))
  • Related