Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Add unit after number and use this for calculation

(0) ShareShare
ReportReport
Posted on by 140

Hello,

 

I have a TextInput field and I add a unit by this expression:

 

 

Text(Value('Arbeitszeit.Gesamt'.Text)*Value('Vorgabe.Auftrag'.Text/100)) & "h"

 

 

But I want to use this TextInput field in another field to calculate the sum. The sum should also have a "h" attached.

How can I do this? 

  • timl Profile Picture
    timl 33,615 on at
    Re: Add unit after number and use this for calculation

    Hi @chhe 

    As a quick summary, to use the text input control values in the calculation, the key step is to remove the "h".

    @mdevaney  uses the standard, and valid technique of calling the Left function to return all the characters in the text input control, minus 1.

    Another method that you might find easier is to strip out the "h" by calling the substitute function. The snippet of code you would use looks like this:

    Substitue('ArbeitszeitSprint.Auftrag'.Text; "h"; "")

    The formula that you would use for your field 3 example would look like this.

    Text(
     Value(Substitue('ArbeitszeitSprint.Auftrag'.Text; "h"; ""))
     +
     Value(Substitue('ArbeitszeitSprint.Kosten'.Text; "h"; ""))
    ) & "h"
    


    Perhaps you could give that a try and see how you get on.

  • chhe Profile Picture
    chhe 140 on at
    Re: Add unit after number and use this for calculation

    I cant calculate with these fields.


    Field 1:

    result: 27,26h - everything fine

     

     

    Value(
     Left(
     Text(Value('Arbeitszeit.Gesamt'.Text)*Value('Vorgabe.Auftrag'.Text/100)) & "h";
     Len(Text(Value('Arbeitszeit.Gesamt'.Text)*Value('Vorgabe.Auftrag'.Text/100)) & "h")-1
     )
    ) & "h"

     

     

    Field 2:

    result: 10,26h - everything fine

     

     

    Value(
     Left(
     Text(Value('Arbeitszeit.Gesamt'.Text)*Value('Vorgabe.Kosten'.Text/100)) & "h";
     Len(Text(Value('Arbeitszeit.Gesamt'.Text)*Value('Vorgabe.Kosten'.Text/100)) & "h")-1
     )
    ) & "h"

     

     

    Field 3:

    This field should calculate the sum from Field 1 and 2.

     

     

    Text(
    Value(
     Left(
     Text(Value('ArbeitszeitSprint.Auftrag'.Text)+Value('ArbeitszeitSprint.Kosten'.Text)) & "h";
     Len(Text(Value('ArbeitszeitSprint.Auftrag'.Text)+Value('ArbeitszeitSprint.Kosten'.Text)) & "h")-1
     )
    )) & "h"

     

     

    The result is: 0h 

    But the result should be 37,62h (27,36h + 10,26h)

     

     

    I cant believe that it is so hard to add a user specific unity... Are there no other ways? 😄

  • mdevaney Profile Picture
    mdevaney 29,987 on at
    Re: Add unit after number and use this for calculation

    @chhe 

    Right, I was simply showing you how to add the numbers.  You can add 'h' at the end the same way @timl showed you previously.

     

    Text(
    Value(
     Left(
     Text(Value('Arbeitszeit.Gesamt'.Text)*Value('Vorgabe.Auftrag'.Text/100)) & "h";
     Len(Text(Value('Arbeitszeit.Gesamt'.Text)*Value('Vorgabe.Auftrag'.Text/100)) & "h")-1
     )
    ) + 100) & "h"

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • chhe Profile Picture
    chhe 140 on at
    Re: Add unit after number and use this for calculation

    Hello,

     

    for a test I have deleted the +100.

    But when I insert the code as follows, there is no "h" behind the value.

     

    Value(
     Left(
     Text(Value('Arbeitszeit.Gesamt'.Text)*Value('Vorgabe.Auftrag'.Text/100)) & "h";
     Len(Text(Value('Arbeitszeit.Gesamt'.Text)*Value('Vorgabe.Auftrag'.Text/100)) & "h")-1
     )
    )
  • mdevaney Profile Picture
    mdevaney 29,987 on at
    Re: Add unit after number and use this for calculation

    @chhe 

    Something like this will do the trick.  Make sure to replace the + 100 with your own value.

    Value(
     Left(
     Text(Value('Arbeitszeit.Gesamt'.Text)*Value('Vorgabe.Auftrag'.Text/100)) & "h",
     Len(Text(Value('Arbeitszeit.Gesamt'.Text)*Value('Vorgabe.Auftrag'.Text/100)) & "h")-1
     )
    ) + 100
    

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,304

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,703

Leaderboard