Forum Discussion
convert a column's data to list
- 3 years ago
Found it! A bit more complicated than I hoped for, but it works:
= Table.AddColumn(#"Changed Type", "Custom", each Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)([Header]))Now if only I could remember how to do it "in column" where it replaces the value in the existing column instead of adding a new one, that'd save another step or two.
Yes - that does function and was what I was hoping was just a workaround :). I was hoping there was a simple way to say "treat the text that's formatted as a list... as a list!". Something like
= Table.AddColumn(#"Promoted Headers", "Custom", each Value.As([Header], List.Type))
But that doesn't work: Expression.Error: We cannot convert the value "{"A", "B", "C ee"}" to type List.
Details:
Value={"A", "B", "C ee"}
Type=[Type]
Found it! A bit more complicated than I hoped for, but it works:
= Table.AddColumn(#"Changed Type", "Custom", each Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)([Header]))
Now if only I could remember how to do it "in column" where it replaces the value in the existing column instead of adding a new one, that'd save another step or two.
- Nruzicka3 years agoNew Member
Hello, maybe a late reply but to transform your existing column to a list type without adding an additional column, try this method:
= Table.TransformColumns("tableName", {"ColumnName", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)})The "transformOperation" argument in "TransformColumns" can have multiple operations. So if you want to convert multiple columns to a list type:
= Table.TransformColumns("tableName", { {"column1", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)}, {"column2", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)} })