web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Leading zeros

(0) ShareShare
ReportReport
Posted on by 23

One of the functions of my app is that the user needs to put in a "test case number." I was testing out random combinations and I noticed that every time I typed in a combination with leading zeroes, the zeroes disappear (for example, 001 turns into 1). Is there a way to keep the leading zeroes that the user types into the text box? 

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @haqian 

    Not if it is a numeric field that you are using.  If it is text, then yes, you could keep them.

     

    Although you could use the Text function to format the number, the question would be, how many leading zeros.  If you know it will always be, say, 4 leading zeros, then you could use : Text(yourfield, "00000")  That would give you 4 leading zeros and a digit.  

    But, if this is random (one could be 2 leading zeros another 5 and so on) and the length for the number is variable, then you will need to store as a string.

     

    I hope this is helpful for you.

  • haqian Profile Picture
    23 on at

    @RandyHayes 

    I believe the text input box I put saves it as a string, but I could be wrong. I set the format as "text" but it still gets rid of the leading zeroes the user types in. Any ideas? 

    haqian_0-1597173611239.png

     

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @haqian 

    Yes, the formatting or text designation would not make a difference here.  You need to look at the type of column that Test Case ID is based on.  If it is numeric, then you will always lose the zeros.  If it is text, then we can dig deeper.

  • haqian Profile Picture
    23 on at

    @RandyHayes 

    I just checked the column and it should be saved as a string. It would make sense for the leading zeroes to go away if it were a numerical value but I'm stumped about why it disappears even if it's saved as a string value. 

    haqian_0-1597174683495.png

     

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @haqian 

    So, the first thing I would look at is the actual data source.  Is the data being stored in the datasource as a string?  Does it have leading zeros in it?  You can click on your datasource in your data source list and choose Edit Data to see what is there.

     

    If it is not there with zeros, then you should look at the Update property for that datacard.  If it is, then you should look at the Default property of the datacard.

  • haqian Profile Picture
    23 on at

    @RandyHayes 

    Thank you so much for directing me to the data source itself! I ended up going into my excel and going into the "format cells" page to change the numbers category to text, so now the leading zeroes are saved in both power apps and excel! 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard