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 Automate / Deduct Value Between T...
Power Automate
Unanswered

Deduct Value Between Two Lists

(0) ShareShare
ReportReport
Posted on by

Hello! I'm trying to build a flow that deducts a value from one list to another; essentially acting as an inventory/delivery flow. 

 

The list I have with the value that needs to be deducted is here:

Applications_1-1654101507470.png

 

The list with the value that should be the deducted amount is here:

Applications_0-1654101402823.png

 

So I need it to recognize the value in the 2nd list in the quantity column, then deduct that value from the quantity in stock column in the first list, once it goes from Pending -> Delivered. How can I make this happen? Thank you!

Categories:
  • Applications Profile Picture
    on at

    Anyone able to assist with this by chance?

  • Applications Profile Picture
    on at

    Good morning all, still looking for support on how to achieve this, if anyone knows how - thank you!

  • Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    The easiest way to do that is going to be to setup a flow on the second list that is triggered when an item is modified. If the status column is delivered then look up the matching entry in list one and update the total by deducting the value. To keep if from firing twice I would add another status to the Pending/Delivered column.  A status of Posted.  In the flow that deducts the value set the status to Posted after it has been deducted.  That will keep it from being deducted twice.

  • Applications Profile Picture
    on at

    That makes sense, I changed column and added that final step, but how would a flow look like to achieve all of this? I've tried a couple where I have:

    1. When a file/item is modified (order list)

    2. get items (inventory list)

    3. set variables (for both number columns in order and inventory list)

    4. subtraction (inventory list by the variables from the order list)

     

    But that didn't work. I'm pretty new to PowerAutomate so any guidance you have would be most appreciated, thanks!

  • Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    1) When an Item is modified Trigger on the second list (the one with the status column). 

    2) Test to see if the Status column is Pending.  If it isn't do nothing (this would be more efficient with a trigger condition)

        a) if it is "Pending" then lookup the corresponding item in the first list (Inventory) and subtract the quantity 

        b) Update the item that originally triggered the flow to status = "Posted"

  • Applications Profile Picture
    on at

    Understood - when I tried to subtract the two columns in the lists I got an error, "Enter a valid number"

    Applications_0-1654530104940.png

     

    Do I still need to set and initialize variables for this?

  • Applications Profile Picture
    on at

    And when I try to initialize them as variables I get this error:

     

    Flow save failed with code 'InvalidVariableInitialization' and message 'The variable action 'Initialize_variable_3' of type 'InitializeVariable' cannot be nested in an action of type 'Apply_to_each_3'.'
     

    Applications_1-1654531381493.png

     

     

     

    How would I go about un-nesting the initialize variable part? Every time I use get items and initialize variable it automatically nests them. 😕

  • Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    Looks like the issue is that you aren't using the Expressions tab in the dynamic content dialog to enter the Sub() function.  Its reading Sub( in your entry as a string not a function.

  • Applications Profile Picture
    on at

    Gotcha, I changed it within the expression builder to this:

     

    Applications_0-1654539282452.png

     

    This is the error I get when testing it:

    Applications_3-1654539494812.png

     

     

     

  • Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    You can't just use the column names in the Expressions Tab.  You either have to switch back to the dynamic content tab and insert the values or type in the JSON addresses of those values.  If you hover over one of the fields you'll see what I mean by the JSON address.  It will be something like 

    items()['ColumnName']

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 Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 389

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 308

Last 30 days Overall leaderboard