cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Add unit after number and use this for calculation

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? 

5 REPLIES 5
Highlighted
Super User
Super User

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."

Highlighted
Helper III
Helper III

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
    )
)
Highlighted
Super User
Super User

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."

Highlighted
Helper III
Helper III

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? 😄

Highlighted
Super User
Super User

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.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (10,916)