Skip to main content

Notifications

Community site session details
Power Apps - Building Power Apps
Answered

Add leading zeros to digits using Text

Like (0) ShareShare
ReportReport
Posted on 17 Apr 2019 20:14:14 by 1,393

I've imported data from an Excel file into a PowerApp. One of the columns is called "SectionNumber" and it may be a 1, 2 or 3 digit number or a single text character. I want to format this such that if it's a number, it's always displayed as 3 digits, with leading zeroes as needed (e.g.: "1" would display at "001").

 

The formula I'm using for this is:

Text(SectionNumber,"[$-en-US]000")

 

I've also tried varying combinations of # and 0 inside the double quotes, but none are producing the output I want. What am I doing wrong here?

  • Verified answer
    timl Profile Picture
    35,085 Super User 2025 Season 1 on 18 Apr 2019 at 10:23:12
    Re: Add leading zeros to digits using Text

    Hi Guys,

    I'm enjoying this conversation!

    @ChadVKealey - I think you did the right thing by adding a column to Excel. It's the quickest and easiest fix.

    But going back to the original question, it seems to me that the simple rule that we're looking for is this.

    If (input is numeric) => convert it to a number and format it
    Else => leave it as it is

    If that's the case, we can apply this type of formula (assuming our input comes from the TextInput1 control):

    If(IsNumeric(TextInput1.Text),
    Text(Value(TextInput1.Text),"000"),
    TextInput1.Text
    )

    (Well done to @LRVinNC for the numeric formatting expression!)

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 250 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 126

#3
stampcoin Profile Picture

stampcoin 115

Overall leaderboard
Loading complete