Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Formatting datacard value to have decimal once out of focus

Posted on by 122

Hi,

 

My user wanted to see that after she have entered an amount ex. 123. it will become 123.00 once out of focus. I only got to the point where it will be formatted after saving using the default property. Wanted to check if my use case is possible in power apps. 

Categories:
  • WarrenBelz Profile Picture
    WarrenBelz 143,591 on at
    Re: Formatting datacard value to have decimal once out of focus

    Hi @powerdevkris ,

    You can do it but very messy. I also assume you want to display existing data source field values in there.
    Firstly, your Text input (Classic Control example here) needs to be set as Text (not Number). Also set the DelayOutput to true
    OnSelect of the Text Input

    UpdateContext({varValue: Blank()})

    also put this after your SubmitForm code and at Screen OnVisible
    . OnChange of the Text Input

    If(
     IsNumeric(Self.Text),
     UpdateContext(
     {
     varValue: 
     Text(
     Value(Self.Text),
     "###.00"
     )
     }
     )
    )

    Now the Default of the Text Input

    Coalesce(
     varValue,
     Text(
     ThisItem.YourNumberField,
     "###.00"
     )
    )

    and last the Update of the Data Card

    Value(YourTextInputName.Text)

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Ami K Profile Picture
    Ami K 15,656 on at
    Re: Formatting datacard value to have decimal once out of focus

    @powerdevkris - not the answer you will want to hear, but it is not possible to format a Text Input control even if the Text Input control is not actively selected. You can however display the formatted value in a separate Label control and hide that Label control conditionally.

     

    For example, when your EditForm is in View Mode, you can hide the Text Input control and make the Label visible, and when the Form is in New or Edit Mode, you can display the Text Input control and hide the Label control.

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard