Forum Discussion
split values into multiple rows
- 9 years ago
Add a custom column with this formula:
= Table.AddColumn(Source, "Custom", each Table.FromColumns({Text.Split([Column2], ";"), Text.Split([Column3], ";")}))and then expand the resulting table.
Where Column2 and Column3 are the names of the columns who have multiple values in them and Source is the name of the previous step or the name of your query that you're referencing.
Edit 2018-10-31: You can also use this more generic function, that saves some typing when using multiple columns:
(Table as table, Delimiter as text, ListOfColumnNames) => Table.AddColumn(Table,
"TableFromColumns",
each Table.FromColumns(List.Transform(ListOfColumnNames,
(x) => Text.Split(Record.Field(_, x),
Delimiter))))
I have data like this:
1, A;B;C, X;Y;Z, 2, 3, 7
It was in Sinlge cell ?
No, not in one cell,
It is comma separated - each comma one cell:
- first cell contains 1
- second cell contains A;B;C
- third cell contains X;Y;Z
- fourth cell contains 2
- etc...
There are of course many rows, this is just one row example.
M.
- Baskar9 years agoResident Rockstar
Cool,
We can do using Power Query, but am not sure it is better way.
My point is we can do everything . Folllow the images step by step .
Your Data etSplit the two column by ( ; )Merge two column like the Example.After merge the three column by ( , )Choose that three column and click Unpivot itRemove Attribute columnSplit the value by ( , )Final Output
Let me know if it is not helping u.
Note :
these all steps u have to do in Query Editor window
- fskhalasm9 years agoFrequent Visitor
Thanks for you suggestion it can help me a bit.
The thing is that the semicomma separated values (A;B;C) are not always three in each row (can be two, three, four, etc - theoretically any count):
1, A;B;C, X;Y;Z, 2, 3, 7
5, A;B;C;D, V;X;Y;Z, 5, 3, 6
2, A;B, Y;Z, 4, 1, 6
- ImkeF9 years agoCommunity Champion
Add a custom column with this formula:
= Table.AddColumn(Source, "Custom", each Table.FromColumns({Text.Split([Column2], ";"), Text.Split([Column3], ";")}))and then expand the resulting table.
Where Column2 and Column3 are the names of the columns who have multiple values in them and Source is the name of the previous step or the name of your query that you're referencing.
Edit 2018-10-31: You can also use this more generic function, that saves some typing when using multiple columns:
(Table as table, Delimiter as text, ListOfColumnNames) => Table.AddColumn(Table,
"TableFromColumns",
each Table.FromColumns(List.Transform(ListOfColumnNames,
(x) => Text.Split(Record.Field(_, x),
Delimiter))))