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 Platform Community / Forums / Power Apps / Text Input number form...
Power Apps
Unanswered

Text Input number formatting based on other Text Input

(0) ShareShare
ReportReport
Posted on by 5

Hi, I am fairly new to PowerApps and am working on an app for scale calibration.   The screen I am working on will  look like the below images.  I have two questions regarding the text input controls on this screen: 

 

1. Is it possible to have PowerApps automatically insert a zero in front of the decimal place in the "Readability" text input field below if the user does not input a zero there.

 

2. Is it possible to format the other text input fields below such that they go out the same number of decimal places as the "Readability" text input field if the user does not type in the zeros.

 

The first image below displays what the screen would look like currently if the user does not add the zeros, and the second screen is what I would like it to look like if the user does not add the zeros.

 

Thank you!

 

CurrentCurrentScreenshot (2).png

                  Desired

Categories:
I have the same question (0)
  • Verified answer
    CarlosFigueira Profile Picture
    on at

    You can do that, but it's not too straightforward. Ideally we would have an "input mask" property in the text input control where you can define a format that will be enforced, but that's not the case today - feel free to create a new feature request in the PowerApps Ideas board, or vote up if one already exists.

    To implement that today, we would need to update the Default property of the text input on its OnChange property - so that we can check whether it is in the expected format, and fix it if this is not the case. So for the first text input control (which I'm calling "txtReliability", which has the Default property set to the 'readabilityDefault' variable), you can have this expression:

    If(
     StartsWith(txtReliability.Text, "."),
     Set(readabilityDefault, "0" & txtReliability.Text); Reset(txtReliability))

    It checks whether the value starts with a '.', and if this is the case, sets the default property with a zero.

    The second requirement is a little trickier. We don't have a direct way to calculate the number of decimal places of a number, but we can use some math (and the Log function) to do that:

    -RoundUp(Log(Value(txtReliability.Text, "en-US")) + 0.000001, 0)

    I used this expression in a label (called 'lblDecimalPlaces', which is visible in the attached app, but would be hidden before you publish it) so that I can refer to that value in the other text input controls.

    Finally, we use a similar logic for the text input controls that hold the values for which you want the standard deviation calculated. We use the Text function to format it with the appropriate number of decimal places.

    Set(
     value1Default,
     Text(
     Value(txtValue1.Text, "en-US"),
     "[$-en-US]0." & Left("00000000000000", Value(lblDecimalPlaces.Text)),
     "en-US"));
    Reset(txtValue1)

    The attached app shows how you could implement this scenario - to open it, download it locally, go to https://create.powerapps.com, select Open, then Browse, and find the file that you saved.

    Hope this helps!

  • matt12354 Profile Picture
    5 on at

    @CarlosFigueira Thank you so much, this is exactly what I was looking for!

    I do have one question, however:

     

    In the following code, why do you add 0.00001 to the log value?

    -RoundUp(Log(Value(txtReliability.Text, "en-US")) + 0.000001, 0) 

     

    Thanks!

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