W
W
wwaavvyy2020-12-07 15:23:39
Google Sheets
wwaavvyy, 2020-12-07 15:23:39

How to add new Cols to the QUERY function?

Hello. I am transferring a table from to another sheet with formatting. More on this in my previous question. How to split cell data separated by commas and transfer to another sheet? How to automate this?
My original table:

spoiler
5fce1d5a0aaf6281262821.png
What happened after using the formula:
spoiler
5fce1dc01b2ab944379104.png
And here is the formula itself:
spoiler
5fce1de50e3e6783481780.png5fce1df782744527265626.png


Now my question (or rather, two):
1) How to make the new sheet have all the columns from the "Data" sheet?
2) How to fix data display in Timestamp column?

Spreadsheet link: https://docs.google.com/spreadsheets/d/1e53AE51FuJ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kishkin, 2020-12-07
@wwaavvyy

P is the column over the horizon, that is, the letter that the rightmost column will have if one more is added. Your last one is O. So the next one is P.

=QUERY(
  ARRAYFORMULA(
    {
      QUERY(
        FLATTEN(IFERROR(SPLIT('Данные'!B:B, ", ", 0))),
        "WHERE Col1 IS NOT NULL",
        0
      ),
      VLOOKUP(
        QUERY(
          FLATTEN(IF(IFERROR(SPLIT('Данные'!B:B, ", ", 0)) = "",, ROW('Данные'!A:A))),
          "WHERE Col1 IS NOT NULL",
          0
        ),
        {
          ROW('Данные'!A:A),
          'Данные'!A:A,
          'Данные'!C:P
        },
        SEQUENCE(1, COLUMNS('Данные'!C:P) + 1, 2),
        0
      )
    }
  ),
    "SELECT Col2, Col1, Col" & JOIN(", Col", SEQUENCE(1, COLUMNS('Данные'!C:P), 3)) & "
     FORMAT Col2 'yyyy-mm-dd hh:mm:ss'",
  1
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question