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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

power query m converts text to numeric but loses the 0 at the beginning of the number

Hi,

power query m converts text to numeric but loses the 0 at the beginning of the number.

For example:

0012 becomes 12

0123 becomes 123

 

try Number.FromText(text as text) as number

or

try Text.From( Number.FromText(text_column_number) in a new column doesn't work.

 

i need to keep the 0.

I haven't found a topic for this case.

Can you help me?

2 ACCEPTED SOLUTIONS
Vijay_A_Verma
Super User
Super User

If you need to keep leading 0s, then you will need to retain the number as text only. Number format will not be able to show leading 0s. In Excel, you can format numbers with leading 0s but here there is no column formatting available on number columns to retain leading 0s. 

View solution in original post

Anonymous
Not applicable

Hi @Anonymous ,

@Vijay_A_Verma Thank you for your replying! This indeed can't be achieved in Power Query, but it can be achieved in table view:
In Model view, choose the data column:

vjunyantmsft_0-1710988251941.png

vjunyantmsft_1-1710988268333.png

Then set it as below:

vjunyantmsft_2-1710988287797.png

The final output is as below:

vjunyantmsft_3-1710988302290.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous ,

@Vijay_A_Verma Thank you for your replying! This indeed can't be achieved in Power Query, but it can be achieved in table view:
In Model view, choose the data column:

vjunyantmsft_0-1710988251941.png

vjunyantmsft_1-1710988268333.png

Then set it as below:

vjunyantmsft_2-1710988287797.png

The final output is as below:

vjunyantmsft_3-1710988302290.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks a lot

Vijay_A_Verma
Super User
Super User

If you need to keep leading 0s, then you will need to retain the number as text only. Number format will not be able to show leading 0s. In Excel, you can format numbers with leading 0s but here there is no column formatting available on number columns to retain leading 0s. 

bhanu_gautam
Super User
Super User

@Anonymous , Try using below method

 

try Text.PadStart(Number.FromText([TextColumn]), Text.Length([TextColumn]), "0")




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Anonymous
Not applicable

It didn't work. it failed to convert text to a number(it offers hasError and noHasError)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.