Skip to main content

Notifications

Community site session details

Community site session details

Session Id : Iey3U1iaxHHDPydpNUSHYV
Power Apps - Building Power Apps
Answered

How to display a percentage in a form field?

Like (0) ShareShare
ReportReport
Posted on 22 Dec 2020 16:41:49 by 2,278

My form is connected to a Sharepoint list.

 

One of the fields is a number, I want to display it as a percentage (it is a tax rate).

 

The DataCard Format property is set to:

 

TextFormat.Number

 

There isn't an option to display this as percentage.

 

So, a tax rate of 0.23 just looks terrible on the form.

 

How can I display it like 23%?

 

Thanks

  • Lawrence_Sprou1 Profile Picture
    40 on 23 Jun 2022 at 18:51:04
    Re: How to display a percentage in a form field?

    The solution for me was to put this in the Default Property for the text input control: 

    Text(Parent.Default,"0.00%")

    This is on a form control so the Parent of the text box is the DataCard.

    If you are not using DataCards you could use whaterver your datasoucre item is. e.g. ThisItem

     

  • Lawrence_Sprou1 Profile Picture
    40 on 23 Jun 2022 at 15:47:29
    Re: How to display a percentage in a form field?

    This does not work for existing data. It only works when one types in new data to the field.

    How can you get the current saved value to format properly? and save properly?

    It displays properly in the SharePoint List as 5%, but in Powerapps is displays as 0.5. 

    When I follow the instructions from this answer, existing values do not display, but new values display correctly. I have not tried to save them, because I do not want to overwrite the existing data, and is suspect that it may cause problems for the list as currently set up. 

    In order to improve the above complex solution, you would need to convert the existing data in the OnSelect Property of the Gallery to the proper format and assign it to the variable, then use the Update Property of the DataCard to convert it back for storage in the SharePoint List.  This worked for me, but there is a simpler solution that I used. I posted it as a separate answer.

  • WebPortal Profile Picture
    2,278 on 30 Dec 2020 at 10:29:49
    Re: How to display a percentage in a form field?

    @v-qiaqi-msft 

    Thank you, that solution almost solves the problem.

    It's not perfect, but it works.

    Ideally, the input should have a "mask" that forces the user to type the value as a percentage. This would facilitate UX. It is easier to type 23 (and see the decimal separator and % in the field as the numbers are typed) than to type .23 (and only see the percentage after the numbers are typed).

    Anyway, it will have to suffice.

     

    BTW: the same goes for other input fields, like phone numbers, email addresses, etc.

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    on 30 Dec 2020 at 09:40:16
    Re: How to display a percentage in a form field?

    Hi@WebPortal,

    Have you solved your problem?

    Based on the issue that you mentioned, do you want to format the TextInput control when you typing within?

    Could you please share a bit more about the scenario?

    I have a test on my side, please take a try as below.

    Set the OnChange property of the TextInput as follows:

     

    Set(var3,Value(DataCardValue8.Text)*100&"%")

     

    Set the Default property of the TextInput as follows:

     

    var3

     

    Note: Please do remember to set the Format of the TextInput as Number.

     Please check the following gif.

    123001Gif.gif

    Hope it could help.

    Regards,

    Qi

  • WebPortal Profile Picture
    2,278 on 22 Dec 2020 at 19:34:40
    Re: How to display a percentage in a form field?

    Ok...

    I thought it was a trivial thing to do and I was missing something.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on 22 Dec 2020 at 19:23:13
    Re: How to display a percentage in a form field?

    You can't easily format a textinput box but you can put "%" in a label next to it. You can format the result from the datasource later. A slider control is a slick way to input the number and you can put a % label next to it.

  • WebPortal Profile Picture
    2,278 on 22 Dec 2020 at 19:17:14
    Re: How to display a percentage in a form field?

    @Drrickryp 

    I'm using a Form and there seems to be no way I can format the fields, they just display raw numbers, like 0.23

     

    For the user, this is annoying. It is better to type: 23%

     

    How do I do that?

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on 22 Dec 2020 at 18:03:54
    Re: How to display a percentage in a form field?

    @WebPortal ,

    Here's an example of how it is used in a label_1.png

  • WebPortal Profile Picture
    2,278 on 22 Dec 2020 at 17:07:17
    Re: How to display a percentage in a form field?

    @Drrickryp 

     

    Thanks, but Where do I type that? I mean, in which object and property?

     

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on 22 Dec 2020 at 16:58:33
    Re: How to display a percentage in a form field?
    Text(0.5,"0%")

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard
Loading started