Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Powerapps Inventory Add Subtract Function not working.

(0) ShareShare
ReportReport
Posted on by 350

Here's the code I'm using. Nothing seems to work. Instead of adding and subtracting the inventory it only inserts the number in my text box.  Instead if should add or subtract from the inventory.  Any help is much appreciated.  

Patch(
tblOptrackInventoryImportedDataCSVS,
LookUp (
tblOptrackInventoryImportedDataCSVS,
FORM_NO = ddl_Form_No.Selected.Value && WAREHOUSE = ddl_From_Warehouse.Selected.Value
),
{ON_HAND: Value("ON_HAND") - Value(txtQuantity.Text)}
);

  • rroque Profile Picture
    350 on at
    Re: Powerapps Inventory Add Subtract Function not working.

    Hi Laurens, hope you're well.   I have a gallery list when the user clicks on a field on the list my app takes them to the detail form. I cannot seem to find the syntax to make the dropdown defaulting from the selected item in the list.  

  • rroque Profile Picture
    350 on at
    Re: Powerapps Inventory Add Subtract Function not working.

    And more importantly is there a good manual out there that I can buy or download?

  • rroque Profile Picture
    350 on at
    Re: Powerapps Inventory Add Subtract Function not working.

    So this inventory portal I'm developing has to add the inventory to warehouse and subtract from warehouse.  

    One of the warehouse is used to replenish inventory.  Here's my code I'm wondering if we can combine or shorten the code a bit.  

    I deduct the from warehouse and add to warehouse.

     

    With(
    {
    //Temp save LookUp value to a function variable for easy reference in the Patch and for the ON_HAND value
    wLookUp: LookUp(
    tblOptrackInventoryImportedDataCSVS,
    FORM_NO = ddl_Form_No.Selected.Value && WAREHOUSE = ddl_From_Warehouse.Selected.Value
    )
    },
    Patch(
    tblOptrackInventoryImportedDataCSVS,
    //Use function variable as record reference
    wLookUp,
    //Use function variable to reference the current ON_HAND column
    {ON_HAND: wLookUp.ON_HAND - Value(txtQuantity.Text)}
    )
    );
    With(
    {
    //Temp save LookUp value to a function variable for easy reference in the Patch and for the ON_HAND value
    wLookUp: LookUp(
    tblOptrackInventoryImportedDataCSVS,
    FORM_NO = ddl_Form_No.Selected.Value && WAREHOUSE = ddl_To_Warehouse.Selected.Value
    )
    },
    Patch(
    tblOptrackInventoryImportedDataCSVS,
    //Use function variable as record reference
    wLookUp,
    //Use function variable to reference the current ON_HAND column
    {ON_HAND: wLookUp.ON_HAND + Value(txtQuantity.Text)}
    )
    )

  • Verified answer
    rroque Profile Picture
    350 on at
    Re: Powerapps Inventory Add Subtract Function not working.

    That worked fine.  Thank you so much brother.  

  • Verified answer
    LaurensM Profile Picture
    12,510 Super User 2025 Season 1 on at
    Re: Powerapps Inventory Add Subtract Function not working.

    Hi @rroque,

     

    Value("ON_HAND") does not refer to the value in that column but rather performs the Value() function on the text value 'On_HAND'. When you want to add / subtract a value from the current state in your table, you can combine the With() and LookUp() functions for easy reference to that current column value. 

     

    With(
     {
     //Temp save LookUp value to a function variable for easy reference in the Patch and for the ON_HAND value
     wLookUp: LookUp(
     tblOptrackInventoryImportedDataCSVS,
     FORM_NO = ddl_Form_No.Selected.Value && WAREHOUSE = ddl_From_Warehouse.Selected.Value
     )
     },
     Patch(
     tblOptrackInventoryImportedDataCSVS,
     //Use function variable as record reference
     wLookUp,
     //Use function variable to reference the current ON_HAND column
     {ON_HAND: wLookUp.'ON_HAND' - Value(txtQuantity.Text)}
     )
    )

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • rroque Profile Picture
    350 on at
    Re: Powerapps Inventory Add Subtract Function not working.

    My equation is in brackets

  • rroque Profile Picture
    350 on at
    Re: Powerapps Inventory Add Subtract Function not working.

    No I have not resolved. No matter what syntaxt I try nothing works.

     

  • rpersad Profile Picture
    726 on at
    Re: Powerapps Inventory Add Subtract Function not working.

    Were you able to solve the issue?

  • rroque Profile Picture
    350 on at
    Re: Powerapps Inventory Add Subtract Function not working.

    Forgot. Thanks 

  • rroque Profile Picture
    350 on at
    Re: Powerapps Inventory Add Subtract Function not working.

    No change it throws an error whenI take the text off.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,702 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard