cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Julien2
Level: Powered On

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
Community Support Team
Community Support Team

Re: Flow: Update Total Item Cost from 2 different lists

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.

Julien2
Level: Powered On

Re: Flow: Update Total Item Cost from 2 different lists

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!

Julien2
Level: Powered On

Re: Flow: Update Total Item Cost from 2 different lists

Hi @v-litu-msft ,
Any suggestions ?

Community Support Team
Community Support Team

Re: Flow: Update Total Item Cost from 2 different lists

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.

Julien2
Level: Powered On

Re: Flow: Update Total Item Cost from 2 different lists

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!

Julien2
Level: Powered On

Re: Flow: Update Total Item Cost from 2 different lists

Hi @v-litu-msft ,

Any news ?

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Speakers, submit your sessions now! Call for speakers ends Feb. 10!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,481)