Forum Discussion
GabrielDC
3 years agoFrequent Visitor
How do I transform this table?
HI All Sorry if this is a rookie question. I have this table [above] with severals months and their items. I'd like to put all the months together in one single column [like the table below]. H...
- 3 years ago
Thanks Greg, your answer inspired me to try something:
1) convert all fields to text type
2) concatenate each month with their respective item
3) Unpivot by these concatenated columns
4) delete the month/items columns
5) Split the concatenated column
6) Profit 🙂
Thanks Greg, we did this!
CNENFRNL
3 years agoCommunity Champion
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WykosUNJRMjbUt9A3MjAyArINIXxzGN9EKVYnWqm0OBFNnRGaOlOwutTcVHSFxmgKzZRiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [region = _t, month1 = _t, item1 = _t, month2 = _t, item2 = _t]),
#"Split to columns" = Table.ToColumns(Source),
#"Combined tables" = let hdr = #"Split to columns"{0} in Table.Combine(List.Transform(List.Split(List.Skip(#"Split to columns"),2), each Table.FromColumns({hdr} & _)))
in
#"Combined tables"