January shows up as 1 and October as 10, so a text sort drops October right after January. To add leading zeros in Power Query, use Text.PadStart: it pads text with 0 on the left up to the length you set.
In this tutorial, we’ll add leading zeros in Power Query to a month number, pull a two-digit month straight from a date, build a Year-Month column, convert a number to text with leading zeros, and compare the DAX FORMAT option.
Here’s the custom column formula that turns the Month number into a two-digit month:
Text.PadStart(Text.From([Month]), 2, "0")
Month 1 comes back as the text 01, Month 2 as 02, and so on.
How does Text.PadStart add leading zeros?
Text.PadStart adds characters to the start of a text value until it’s a set length. You use it inside a custom column, so it helps to know how to add a column in the Power Query Editor first.
Text.PadStart(text as nullable text, count as number, optional character as nullable text) as nullable text
| Parameter | What it does |
|---|---|
| text | The value to pad. It must be text, so wrap numbers in Text.From() |
| count | The final length you want, such as 2 for a month or 5 for a ZIP code |
| character | The pad character. Leave it out and Power Query pads with spaces, so always pass "0" |
That third argument trips people up. Without it, the month 1 becomes a space followed by 1, which looks right in a table but won’t match 01 anywhere.
Add a leading zero to the month in Power Query
I tested every formula here on a 60-row sales file (C:\SPGuidesDemo\PowerBI\SPGuides_Sales_2026.csv) with orders from January to September 2026. Load it with Get data > Text/CSV, then select Transform data.
First, get the month number. Select the OrderDate column, then go to Add Column > Date > Month > Month:

Power Query adds an Inserted Month step that uses this function and types the column as a whole number:
Date.Month([OrderDate])
The new Month column shows 1, 2, 3 with no zero. If you’d rather show January or Feb, see how to convert a month number to a month name instead.
Now go to Add Column > Custom Column, name it Month 2 Digit, and enter the Text.PadStart formula. Select OK and check the formula bar:
Table.AddColumn(#"Inserted Month", "Month 2 Digit", each Text.PadStart(Text.From([Month]), 2, "0"))

Every row now reads 01, 02, 03 and so on. The column header