Condense a multi-row, multi-column formula output into a single row

流过昼夜 提交于 2019-12-11 08:36:53

问题


I have a QUERY formula that imports the first three rows of some data, "Select Col1, Col2 Order by Col2 desc limit 3", producing an output like this:

   |   c1   | c2
r1 | Red    | 53
r2 | Blue   | 45
r3 | Yellow | 15

I'd like to get need those same formula values to look like this:

   |  c1  |  c2  |  c3  |  c4  |   c5   |  c6 
r1 | Red  |  53  | Blue |  45  | Yellow |  15

where the whole output is in a single row.
Is this possible?


回答1:


Yep, wrap your query function with TEXTJOIN

=TEXTJOIN(" ", TRUE, QUERY(....))

To get multiple columns, you would wrap this with SPLIT, and instead of joining on " ", join with some arbitrary delimiter that is guaranteed to not be in the query result. If you expect a wide variety of text to be a possible formula result, you may need to get quite creative, or use unicode.

=SPLIT(TEXTJOIN("-;-", TRUE, QUERY(....)), "-;-", FALSE)



回答2:


=ARRAYFORMULA(SPLIT(CONCATENATE(QUERY()&"🙀"),"🙀"))
  • Concatenate the query result with a Weary cat
  • Split the cat


来源:https://stackoverflow.com/questions/49309180/condense-a-multi-row-multi-column-formula-output-into-a-single-row

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!