Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Pbix_is
Advocate I
Advocate I

How do I determine if value in text type column contains only numbers

Hello!

I have a column type text where some values are only numbers and start with many zeros 00000000000123.

Other values are text only or are combination of text, characters and numbers; sample:

Pbix_is_1-1660671990951.png

 

Goal is to trim first zeros, but ONLY from values that contain only numbers (so e.g. 00E2 should keep zeros after transformation, but above 00000000123 should be 123). 

I wast trying to duplicate column and change type of column to decimal number  -  then keep values from this column if there is no error, and from the original column if I get errors in the second column.

BUT some lines that contain text get transfered to number (these become zero):

Pbix_is_0-1660671539240.png

Do you have a better idea to solve this or you know why these become zero? 

Thank you in advance!

1 ACCEPTED SOLUTION
latimeria
Solution Specialist
Solution Specialist

Hi @Pbix_is ,

Try this:

Table.AddColumn(Source, "Custom", each try Number.ToText(Number.From(Text.TrimStart([Column1],"0"))) otherwise  [Column1], type text)

View solution in original post

3 REPLIES 3
latimeria
Solution Specialist
Solution Specialist

Hi @Pbix_is ,

Try this:

Table.AddColumn(Source, "Custom", each try Number.ToText(Number.From(Text.TrimStart([Column1],"0"))) otherwise  [Column1], type text)

Thank you!! It does solve all that I described above!

These came up, however, so I think I will add condition if text contains "E" or "." keep first column. 

Pbix_is_0-1660728767044.png

 

Pbix_is
Advocate I
Advocate I

Oh, forgot to mention: in Power Query Editor 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors