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

Deduct Value Between Two Lists

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!

10 REPLIES 10
Applications
Helper IV
Helper IV

Anyone able to assist with this by chance?

Applications
Helper IV
Helper IV

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

Pstork1
Dual Super User
Dual Super User

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.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

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
Dual Super User
Dual Super User

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"



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

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
Helper IV
Helper IV

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

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.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

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

 

 

 

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']



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (4,492)