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?
Solved! Go to Solution.
Thanks @timl. That's precisely what I had in mind when I asked about how the single character value should be displayed.
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.
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"
@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.
You would add the Text formula to your Update property of the datacard.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
259 | |
126 | |
86 | |
85 | |
68 |