Forum Discussion
Add text after numbers
- 6 years ago
Hi aso1 ,
You could try below M code to see whether it work or not.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTVMzJVitUBssz0jM3ALCMjPQMDiJipsZ4ZlGVmqWdsDFFqZKhnZGgCZMcCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type number}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Number.ToText([Column1]) & " GB"), #"Sorted Rows" = Table.Sort(#"Added Custom",{{"Column1", Order.Ascending}}), #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1) in #"Added Index"By the way, when you add "GB" after numbert, the column type will change to text, so it will sort by alphabetically. You need to create an index or rank column, then set it sort by index or rank column, it should work.
Best Regards,
Zoe ZhiIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hi Pragati!..
thanks. am I doing it right?... I get this error :
- aso16 years agoHelper II
this worked.
last thing : I would like only two digits after the dot. for example "23.99 GB"
How can I achieve this?..
- aso16 years agoHelper II
also, I cannot sort in order.. it does not work. why is that?
- dax6 years agoCommunity Support
Hi aso1 ,
You could try below M code to see whether it work or not.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTVMzJVitUBssz0jM3ALCMjPQMDiJipsZ4ZlGVmqWdsDFFqZKhnZGgCZMcCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type number}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Number.ToText([Column1]) & " GB"), #"Sorted Rows" = Table.Sort(#"Added Custom",{{"Column1", Order.Ascending}}), #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1) in #"Added Index"By the way, when you add "GB" after numbert, the column type will change to text, so it will sort by alphabetically. You need to create an index or rank column, then set it sort by index or rank column, it should work.
Best Regards,
Zoe ZhiIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.