Search code examples
arraysgoogle-sheetsgoogle-sheets-formulagoogle-sheets-querygoogle-query-language

Change the text of all cells in a specific column in a Query () function


I have the following query to combine three tabs in a Google spreadsheet:

=QUERY({'Stock 1'!A:N;'Stock 2'!A2:N;'Stock 3'!A2:N};"Select Col1, Col2, Col3, Col4 Where Col3<>''";1)

In the grouped tab (Total Stock) I want to change all cells of column D (Col4) to "Company 1"

Is there any function similar to "set" in SQL?

Example:

https://docs.google.com/spreadsheets/d/1zGaka_DK5SPeRE-LAB7pK7NJ6I9bRUx4G6cgb_4inGg/edit#gid=2081907934


Solution

  • try:

    =QUERY({'Stock 1'!A:D; 'Stock 2'!A2:D; 'Stock 3'!A2:D}; "where Col1 is not null"; 1)
    

    0


    or:

    =QUERY({'Stock 1'!A:D; 'Stock 2'!A2:D; 'Stock 3'!A2:D}; 
     "select Col1,Col2,Col3,'Company X' where Col1 is not null label 'Company X''Company'"; 1)
    

    0