Forum Discussion
Transforming a column with different data format
You can use List functions to get your desired result, starting with Text.Split(). Use the expression below in a Custom Column. Also, you can paste the below M code into a blank query (paste over the existing text in Advanced Editor), to see how to do it.
= List.Average(List.Transform(Text.Split([Column1],"-"), each Number.FromText(_)))
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUjExMDBQitUBsozMDQx0VUwsQfxYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Average(List.Transform(Text.Split([Column1],"-"), each Number.FromText(_)))),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Currency.Type}})
in
#"Changed Type1"
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat