cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ChadVKealey
Power Participant
Power Participant

Add leading zeros to digits using Text

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?

17 REPLIES 17

Thanks @timl.  That's precisely what I had in mind when I asked about how the single character value should be displayed.  

LRVinNC

------------------
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
accorti
Helper I
Helper I

Will this method always add 2 - leading 0's to the input or will it adjust to fit the 3 digit criteria?

 

i.e. 

1 = 001

2 = 002

...

10 = 010 or 0010


@accorti wrote:

Will this method always add 2 - leading 0's to the input or will it adjust to fit the 3 digit criteria?

 

i.e. 

1 = 001

2 = 002

...

10 = 010 or 0010


This returns the number 1 so that it is 3 digits long and fills in leading zeroes as needed: 001

Text(1,"000")

 

If you try the "000" format against a number that is longer than 3 digits, it will exceed 3 digits: 1000

Text(1000,"000")

 

What are you looking to do?

I'm trying to do something similar but on a number field, for instance for Month (1 would be 01), etc. I have my number field set to only be 2 digits.

RandyHayes
Super User
Super User

@kmw1130 

A number column will never have leading zeros.  Leading zeros is about "format" of a number.  So, you will not be able to store a number as 01 in your data numeric column.  You can store it in a text column as such.

If you are trying to go the other way with it - you have 1 in the number column and want to display 01 - then use the following : Text(yourNumberColumn, "00")

i.e. Text(1, "00") will show "01"

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes I changed my SharePoint field to Text vs Number.  Do I add this formula to the DataCardValue Default formua?

@RandyHayes I have the formula working, when it is saved to my SharePoint list, it is still doesn't add the leading 0.

RandyHayes
Super User
Super User

@kmw1130 

You would add the Text formula to your Update property of the datacard.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,017)