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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Number.ToText not working as expected

Hi all, 

trying to add leading Zeros in front of my live query in an extra column. The result must always 8 digits long including the leading zeros

I tried:

Number.ToText ( [Number], "0000000"))

not showning zeros in front of

Number.ToText ( [Number], "d8"))

not showning zeros in front of

Text.End("0" & Text.From([Number]),8)

shows only one leading zero instead of multiple to fill till 8 digits are reached

Text.PadStart (Text.From( [Number]),8,"0")

works, but is not allowed in live queries

 

Any idea how to fix this in a live query?

 

 

1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi,

 

Text.End("00000000" & Text.From([Number]),8)

 

Text.Repeat("0", 8-Text.Length(Text.From([Number]))) & Text.From([Number])

Stéphane 

View solution in original post

2 REPLIES 2
dufoq3
Community Champion
Community Champion

dufoq3_0-1705597636234.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMjODUKZACGFZmgGRJUzY0gKqzBhMQ0hTCNtEB6rbyMICyARrigUA", 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 number}}),
    NumberToText = Table.AddColumn(#"Changed Type", "NumberToText", each Number.ToText(Number.From([Column1]), "00000000")),
    TextPadStart = Table.AddColumn(NumberToText, "TextPadStart", each Text.PadStart(Text.From([Column1]), 8, "0"))
in
    TextPadStart

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

slorin
Super User
Super User

Hi,

 

Text.End("00000000" & Text.From([Number]),8)

 

Text.Repeat("0", 8-Text.Length(Text.From([Number]))) & Text.From([Number])

Stéphane 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors