Forum Discussion
gehe_muc
4 years agoFrequent Visitor
Costum Column: Build a string with a separator based on the number in another column
Helle everybody, I need a custom column with a string, based on another column with a number: Thanks for your kind help! Steve
- 4 years ago
Hi gehe_muc ,
Here you go. Copy and paste this M-code in a blank query and you'll be able to see the steps.let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlWK1YlWMgaT5mDSEExaKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Number = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Number", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {1..[Number]}), #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ";"), type text}) in #"Extracted Values"Final result
Main idea is to create a list of numbers starting from 1 to <value_in_column>
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂
rohit_singh
4 years agoSolution Sage
Hi gehe_muc ,
Here you go. Copy and paste this M-code in a blank query and you'll be able to see the steps.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlWK1YlWMgaT5mDSEExaKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Number = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Number", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {1..[Number]}),
#"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ";"), type text})
in
#"Extracted Values"
Final result
Main idea is to create a list of numbers starting from 1 to <value_in_column>
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂
gehe_muc
4 years agoFrequent Visitor
Thanks Rohit, works very well - 😊