web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Sum or subtraction of ...
Power Apps
Answered

Sum or subtraction of 2 values in text fields

(0) ShareShare
ReportReport
Posted on by 18

I would like to calculate values from 2 text fields. + or -
The selection should be made using by a dropdown menu. Ideally, the subtraction value must not be greater than the value in text box 1 to prevent a negative result.
As I am a complete beginner, I am not getting anywhere with this simple topic. Thanks a lot

 

René

Categories:
  • eka24 Profile Picture
    20,925 on at

    Can you give more details. How does the drop-down came in. Where are you placing the sum results. Are you summing textfields or columns directly in the Table.

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @renedd78,

    Based on the issue that you mentioned, do you want to calculate the value based on the Dropdown selcted?

    Could you please tell me that if you populate the Dropdown box with the option of Sum and Subtraction?

    Here is my scenario, please check as below.

    Add a Dropdown and set Items as to:

    ["Sum","Subtraction"]

    Set the Default property of the TextInput corresponding to calculation result as to:

    If(
     Dropdown2_1.Selected.Value = "Sum",
     Sum(
     DataCardValue24.Text,
     DataCardValue25.Text
     ),
     If(
     Dropdown2_1.Selected.Value = "Subtraction" && Value(DataCardValue24.Text) >= Value(DataCardValue25.Text),
     (DataCardValue24.Text) - (DataCardValue24.Text)
     )
    )

    In addition, to prevent that the subtraction value is greater than the value in text box 1, please add a Label within and set the Text as to:

    "Negative result is not allowed!"

    Set the Visible as to:

    If(Value(DataCardValue25.Text) > Value(DataCardValue24.Text),true,false)

    Notice that DataCardValue24 represents text box 1, DataCardValue25 represents text box 2

    Hope it could help you.

    Regards,

    Qi

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 360 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 325

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard