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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
lottie2404
Frequent Visitor

HELP: Adding Leading Zeros in Power Query

Hello

How do I add "0" to a column that has 5 digits, the columns should have 6 digits, but due to an error it was loaded without the leading zero.

 

Could you explain me the process because I am new in power query, would I have to generate a new column? or modify the one I have?

2 REPLIES 2
Anonymous
Not applicable

Hi @lottie2404 ,

 

I guess this column is automatically converted to an whole number type.

vcgaomsft_0-1679986883593.png

You can add a step to fix it by reconverting it to text type.

= Table.TransformColumns(#"Changed Type",{"Column1",each if Text.Length(Text.From(_))<6 then "0"&Text.From(_) else Text.From(_)})

vcgaomsft_1-1679986950564.png

Of course, if the column is of the correct type in the Source step you can unconvert it in the second step.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Anonymous
Not applicable

You can create a custom column (first make sure the column is changed to type text) using:

 

=Table.AddColumns(PriorStepOrTableName, {{"Padded", each Text.PadStart([NumberColumnName], "0", 1), type text}})

 

--Nate

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.