cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MrAutomate
Advocate I
Advocate I

PowerApps number formatting

Need help on a powerapps number field (sharepoint list).

 

This will track Teammate temperature daily.  I do not want the operator to need to search for the decimal point on the iPad virtual keyboard to enter 98.7 or 100.3

 

I would like the operator  to enter 987 (3 Digits) and powerapps convert that to 98.7 and save the record when they press save.

If they enter 1003 (4 digits) convert that tp 100.0 and save the records.

 

Is this possible ?

 

Thanks!

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @MrAutomate ,

Put this on the OnChange of the Text Box

UpdateContext(
   {
      var1No: Text(
         Value(Self.Text) / 10,
         If(
            Len(Self.Text) < 4,
            "[$-en]##0.0",
            "[$-en]##0"
         )
      )
   }
);
Reset(Self)

then the Default of the Text Box (assuming it is in a Form)

If(
    Value(var1No) > 0,
    var1No,
    Parent.Default
)

If not in a Form, you can leave off the Parent.Default

 

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.

 

 

 

View solution in original post

@MrAutomate ,

You are probably better clearing the Variable on screen OnVisible and/or on the selection of a another/new record (I forgot the mention this and you should, as you have worked out, do it)

I have seen some unexpected behavior setting and resetting variables in the same piece of code  when something relies on it in the middle.

 

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.

 

 

View solution in original post

5 REPLIES 5
WarrenBelz
Super User
Super User

Hi @MrAutomate ,

Put this on the OnChange of the Text Box

UpdateContext(
   {
      var1No: Text(
         Value(Self.Text) / 10,
         If(
            Len(Self.Text) < 4,
            "[$-en]##0.0",
            "[$-en]##0"
         )
      )
   }
);
Reset(Self)

then the Default of the Text Box (assuming it is in a Form)

If(
    Value(var1No) > 0,
    var1No,
    Parent.Default
)

If not in a Form, you can leave off the Parent.Default

 

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.

 

 

 

View solution in original post

it looks like I provided ambiguous requirements, apologies 😞  , I fixed the else portion as follows:

"[$-en]###0.0"

This solves if they enter 1004 as 100.4.

 

Works like a charm, Many thanks!

 

 

Hi Warren:

 

Small issue - The reset does not appear to be clearing the temperature after saving the form(this can cause operator error if they are not paying attention) .  The actual value is stored in DatacardValue8.  I tinkered around trying to clear the var1No: on form save, but I was not successful.  Any thoughts?

MrAutomate
Advocate I
Advocate I

got it:  I put this on my save button...   UpdateContext({var1No: Blank()})   worked.  I was trying to clear the contexct variable using SET, which was wrong...   Thanks again

@MrAutomate ,

You are probably better clearing the Variable on screen OnVisible and/or on the selection of a another/new record (I forgot the mention this and you should, as you have worked out, do it)

I have seen some unexpected behavior setting and resetting variables in the same piece of code  when something relies on it in the middle.

 

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.

 

 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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