Forum Discussion
Syndicate_Admin
Administrator
5 years agoExtract leading zeros from a column with data type text
Hello I have a column with both numeric and text values, but in power BI it is defined in text (because otherwise the texts would not be displayed and it is necessary). When this happens, the num...
Greg_Deckler
Community Champion
5 years agoSyndicate_Admin Perhaps
=Text.TrimStart([Column1], "0")- Syndicate_Admin5 years ago
Administrator
Gràcias for the answer, but I do not solve the probema since that function also removes the zeros from the values :
00400-C10 00120-C24 - Greg_Deckler5 years ago
Community Champion
Syndicate_Admin Sorry, I'm not seeing that behavior or I am not understanding your exact needs:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjAwMTDQdTY0UIrVAfEMjYA8IxMoDwJMwISpsbEBUFUsAA==", 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 Text.TrimStart([Column1], "0")) in #"Added Custom"- Syndicate_Admin5 years ago
Administrator
Look yes! precisely in that image you see the problem to your solution.
As I comment, what I want to get is:
4000453300 00400-C10 00120-C24 With your solution, I get rid of the zeros of all cases. In the original explanation I comment that I just want to remove the zeros from the values that are integers and that the values that are alphanumeric keep the zeros.
That those that have been marked in yellow have the zeros removed and that those that have been marked in green remain the same.