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

Adding values together

So I have a few input text boxes that operate off of an "IF" statement (see below): 

ianallen13_0-1644613934238.png

We'll say that it goes...

A1, A2

B1, B2

C1, C2

D1, D2

 

I just want to create a field that adds all the values A1, B1, C1 & D1 together (so it should be 4)

Same for A2, B2, C2 & D2 - just want a field that adds all those values up.

 

Then I have another field that is defaulted at "2", so I want to divide that field over these two field requests above.  So for example: 

 

2/4 = 50% 

 

Any ideas?

 

I'm sure this is super easy, but I'm blanking on this at the moment.  

 

@AJ_Z - any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
PowerRanger
Resident Rockstar
Resident Rockstar

@ianallen13 If I got your question right your formular should look something like that:

(Value(textboxA1.Text) + Value(TextboxB1.Text) + .....) / Value(TextboxFixValue.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.




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

View solution in original post

8 REPLIES 8
PowerRanger
Resident Rockstar
Resident Rockstar

@ianallen13 If I got your question right your formular should look something like that:

(Value(textboxA1.Text) + Value(TextboxB1.Text) + .....) / Value(TextboxFixValue.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.




​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.
ianallen13
Helper IV
Helper IV

You did - thank you.  So simple, but this totally makes sense.  Appreciated! 

ianallen13
Helper IV
Helper IV

How do I show it as a %? 

@ianallen13 you mean how to calculate that it will show 50% or how you can add the % Charakter? 




​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.
ianallen13
Helper IV
Helper IV

The 50% - but I just figured it out.  Thank you again! 

@ianallen13 Glad you solved it. But I do want to show you another approach which might come in handy when Dealing with a lot of numbers

 

With(
    {
        A1: Value(txtA.Text),
        B1: Value(txtB.Text),
        C1: Value(txtC.Text),
        D1: Value(txtD.Text),
        Devider: Value(txtDevider.Text)
    },
    Devider / (A1 + B1 + C1 + D1) * 100
) & "%"

 

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.




​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.
RandyHayes
Super User
Super User

@PowerRanger 

How about another one...

Value(txtDevider.Text) /  Sum([txtA, txtB, txtC, txtD], Value(Value.Text)) * 100

 

PowerApps LOVES tables!!  In the above, the trick is that we are providing a table to the Sum function (which loves tables).  The table happens to be of controls - not values or any other property.  Since we use the square bracket syntax for the table, PowerApps will automatically create a table with a Value column.  The value in the column will be a control.  Then we do the conversion on the Text to sum.  In that case we are getting the Value (text to number) of the Value (column name) and the .Text property (column).

 

This shortcut is very easy to add to if you end up with more controls to sum.  

 

The only thing to keep in mind - PowerApps is VERY particular about schema.  So in the above, the txt controls need to ALL be the same type of control.  You could not use labels and TextInput at the same time as the two controls have different schemas.  BUT, if you end up with different control types, then you can just specify the property in the table.  Ex.  Sum([txtA.Text, txtB.Text, txtC.Text, txtD.Text], Value(Value))   IN this case, the .Text property definition moves to the table, so it is not needed in the Value...it is already there!

 

Enjoy!!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
ianallen13
Helper IV
Helper IV

Thank you guys!  Appreciate and love the help! 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (2,339)