cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
anonymia25
Helper IV
Helper IV

Format input box with 1 decimal place

Hello,
I have a gallery with number type input boxes. I wanted the input box to auto update and format to only accept 1 decimal place while still in edit mode. How do I do that? Thank you.

 

Text(Value(ThisItem.Weight),"[$-en-US]#.0")

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @anonymia25 ,

With difficulty in a gallery if you want to work on more than one record   . . . you are wanting to reset a control in the gallery to a different value to the one input and the only way to do this is with a Variable. You can of course restrict the record to the one selected and it will work fine BUT if you select another record, the variable is still true AND the record is now selected, so it will reset as well (as you have discovered). I would simply save each record as you change them and reset the Variable to false when you save.

 

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.

Visit my blog Practical Power Apps

View solution in original post

7 REPLIES 7
WarrenBelz
Super User
Super User

If you only want to see one decimal place immediately after the user has input the data - OnChange of the Text Box

UpdateContext(
   {
      var1Decimal: 
      Round(
         Value(Self.Text),
         1
      )
   }
);
Reset(Self)

Default of the Text Box (call the Variable whatever you wantg)

var1Decimal

 

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.

Visit my blog Practical Power Apps

 

Ramole
Super User
Super User

Hi @anonymia25 
Try this simple formula please

Text(Value(ThisItem.Weight),"#,###,##0.0")

 

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.

Hi @WarrenBelz,
This work well when editing and it helped convert the value correctly, but unfortunately I have the input box/ textbox in a gallery. So, since Self.Text is used I noticed all rows for the weight are changed into the same value instead. How do I only change the specific row value?

anonymia25_0-1646380354533.png

 

Hi @anonymia25 ,

Try on the Default

If(
  ThisItem.IsSelected,
  var1Decimal
)

Note however you will need to reset this variable before the user selects another row. 

 

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.

Visit my blog Practical Power Apps

Hi @WarrenBelz ,
i have tried your solution above but apparently the weight is reset each time?
gif_weight.gif

Currently this is what I have on my Default: 

If(
  ThisItem.IsSelected,
  var1Decimal, ThisItem.Weight
)

 
and i don't get what you mean by to reset the variable before the user selects another row. how do i apply that? 

Hi @anonymia25 ,

With difficulty in a gallery if you want to work on more than one record   . . . you are wanting to reset a control in the gallery to a different value to the one input and the only way to do this is with a Variable. You can of course restrict the record to the one selected and it will work fine BUT if you select another record, the variable is still true AND the record is now selected, so it will reset as well (as you have discovered). I would simply save each record as you change them and reset the Variable to false when you save.

 

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.

Visit my blog Practical Power Apps

Hi @WarrenBelz,
Thank you for your help! It worked finally and I did save each record by patching all the row items onChange and reset the variable to false right after the patch. :))

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,390)