问题
Given this data:
How do I transform it to look like this:
There are two columns in the data source, key
(title
) and value
(responsibility
).
I need to transform it such that we have the key
column (title
) and then n
columns where n
is the highest number of value
a key has, eg 3 in the picture above. Hence the columns should be:
Title, 1, 2, 3
.
The values in each column 1, 2, 3
should be corresponding to values in the original data.
Any combination of formula is welcomed - I believe a combination of Transpose
and/or Query
(pivot
) is appropriate but I cannot put it together.
In case this is too complex we can put an enumeration directly in the data source, but it would be nice to be able to have the formula work without it. Eg:
Example sheet: https://docs.google.com/spreadsheets/d/1InYZ12VuuaSg0s3fiFTCx8BnwEan5JsqpsNBF973lWc/edit?usp=sharing
回答1:
try:
=QUERY({A:C},
"select Col1,max(Col3)
where Col1 is not null
group by Col1
pivot Col2", 1)
or:
=ARRAYFORMULA(QUERY({A:A, COUNTIFS(A:A, A:A, ROW(A:A), "<="&ROW(A:A)), B:B},
"select Col1,max(Col3)
where Col1 is not null
group by Col1
pivot Col2", 1))
来源:https://stackoverflow.com/questions/60191001/transform-one-to-many-data-to-columns