I'm struggling to write a query that appears more complex than anticipated, here a sample of the data to process
CW6 | CW7 | CW8 | CW9 |
---|---|---|---|
A | B | C | A |
B | D | E | B |
Here the result expected at the end:
Item | CW |
---|---|
A | "CW6 CW9" |
B | "CW6 CW7 CW9" |
C | "CW8" |
D | "CW7" |
E | "CW8" |
Any idea how to achieve this ? What I've tried in many steps:
=transpose(query(<data>,"Select *",1))
to transpose my data
Then I used
=transpose(
query(
transpose(<data transposed>),,9^9
)
)
to join all columns
Then I select all the unique values I want to retrieve the column header (CWxx)
=query(
unique(flatten(<Data>)),
"Select Col1 where Col1 is not null"
)
Finally I join the data that were transposed to get it in one string (ie 1 column):
=JOIN(" ", QUERY(< data transposed and joined>,"SELECT Col2 WHERE Col1 contains '"&A1&"'",0))
At the end I got the wanted array but I have to copy the last join formula on each line what I do not want to do as my values are dynamic
Any idea how to achieve this (or a simpler way to avoid all these steps) ?