cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Julien2
Post Prodigy
Post Prodigy

Flow: Update Total Item Cost from 2 different lists

Hello everyone!

 

I have 2 lists in SharePoint one called "Sales Invoices" and "Sales Data".

 

Sales Invoices consist of the following columns:
(Invoice ID,Invoice Name,Total Invoice Cost).

 

Sales Data consist of:
(Invoice Items ID:is lookup from Sales Invoices, to get information from Invoice ID in Sales Data) Item Name,Quantity,and Cost.

What i want to achieve is the following:
Each Invoice contain multiple items with different costs.
I want to get the Sum Cost of the Invoice ID from Sales Data and Update the Total Invoice Cost in Sales Invoices.

I have created a flow but only get the item cost,while i need to get Total Invoice Cost here are screenshots:
I have 2 items in Sales data for the same invoice id, the total cost should be 65$ for both items, so it should update in "Sales Invoices list" the Total Invoice Cost to 65$.

Cap1.PNGCapture.PNG

Flow screenshot:

Capture1.PNG

 

What will be the flow to achieve the scenario mentioned above,even when i update any items cost  ?

 

Any help will be greatly appreciated.

 

Thank you!

6 REPLIES 6
v-litu-msft
Community Support
Community Support

Hi @Julien2,

 

You can initialize a integer variable and set its default value to 0, then Get items of the Sales Date list, use the Increment variable action to sub these cost, you can get these cost by enter the expression item()?['Cost'], after the loop through the integer variable will be total cost, put the variable into the Update item action:

Annotation 2019-12-12 140007.png

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-litu-msft ,

 

I have followed the steps you mentioned but as flow result here is what i get:

Capture2.PNG

Also i have tried instead of using Set Variable, i have added a compose action using this expression:

 

"@int(item()?['Cost'])"

 

But also the flow fails without updating the Total Invoice Cost column.

I will recap what i want to achieve:
Here the Invoice Items ID 3 has a total sum of 280$, i want to update this number in the Sales Invoices list for Invoice ID 3.

Capture3.PNGcap4.PNG

Thanks in advance!

Hi @v-litu-msft ,
Any suggestions ?

Hi @Julien2,

 

There is increment variable action in the Apply to each action, not set variable action.

And the field in the set variable should be a integer, please make sure the Cost field has value and its format is integer.

 

If you want to get the result you want, I think there is no a easy way to do in Flow, it might be a complicated Flow.

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-litu-msft ,

Good point i didn't know that there is an increment variable action. Now after i have modified the flow, it ran successfully.But as result i didn't achieve the right results.

Here are the Total amount of Invoice ID's 4 and 5: where Invoice 4 = 50$ and Invoice 5 = 50$:

Sales Data.PNG

In the Sales Invoices list here are the results:

Capture.PNG

It count the rows and update the Total Invoice Cost to the row counted. While it should trigger the other list Invoices ID's amount and update the right total invoice cost amount result for each invoice id.

Here is the flow result:

Capture2.PNG

If there is no easy way to do it in Flow, what would be this complicated flow to achieve it ?

 

Looking to hear from you. Thanks for your support!

Hi @v-litu-msft ,

Any news ?

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,383)