Skip to main content
Community site session details

Community site session details

Session Id : TN393Z9UOrHL1BGKxUuf9n
Power Apps - Building Power Apps
Answered

Make number negative based on other field

Like (0) ShareShare
ReportReport
Posted on 25 May 2022 01:10:50 by 5

Hello, 

 

Is there a way to set a field negative based on another field without making the number field a text field? 

 

Here's what I'm trying to do:

If the Movement fields shows Remove, I would like the number in the Quantity section to automatically be negative. If the Movement field shows Add, then leave the number as is. When the data field is number, it does not allow me to input a negative. 

 

Any help would be greatly appreciated. 

 

Thank you!

 

Remove

zerodarkbirdy_0-1653440831403.png

 

Add

zerodarkbirdy_1-1653440891106.png

 

  • zerodarkbirdy Profile Picture
    5 on 08 Jun 2022 at 22:24:55
    Re: Make number negative based on other field

    Looks like this worked! Thank you! I had to rearrange the fields so that the quantity is inputted first and not the movement,  but other than that the change worked great. Thank you for you help. 

  • Verified answer
    v-liwei-msft Profile Picture
    on 31 May 2022 at 09:50:18
    Re: Make number negative based on other field

    Hi @zerodarkbirdy ,

     

    1. you can use the switch function to determine: when "movement" is "add" ,the "amount" is 10; When "movement" is "remove", the "amount" is -10.

    2. When "movement" is "remove", you can convert the amount to a string and then add "-" and then use the value function to convert the string to a number.

    I have made a test for your reference:
     
    Switch(
    DataCardValue2.Selected.Value,
    "add",
    ThisItem.quantity,
    "remove",
    Value("-" & Text(ThisItem.quantity))
    )
     
    vliweimsft_0-1653990587584.png

     

     

    Best Regards,

    Levi

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

Announcing our 2025 Season 2 Super Users!

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!