web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to sum values from...
Power Automate
Unanswered

How to sum values from one Sharepoint list to another based on unique value.

(1) ShareShare
ReportReport
Posted on by 5

Looking for a bit of guidance on setting up a flow to sum values from one SharePoint list to another based on unique identifier.

 

Scenario

I have ListA that contains an inventory of items and quantity purchased. The Title (single line of text) field will be a unique name in this list, with the Quantity purchased field being a Number field.

 

ListA Example:

TitleQuantity PurchasedQuantity Used
Item150 
Item225 

 

ListB contains a list of the items and the quantities used. Again with Title being a single line of text, and the Quantity Used being a number

 

ListB Example:

TitleQuantity Used
Item110
Item25
Item110
Item110

 

The end goal would be to sum the values for each item from ListB (when a new item is added to the list) and update the corresponding items Quantity Used field in ListA.

 

ListA After flow has ran:

TitleQuantity PurchasedQuantity Used
Item15030
Item2255

 

 

 

Thank you,

 

Categories:
I have the same question (0)
  • Verified answer
    v-LilyW-msft Profile Picture
    on at

    Hi @twoods 

    I set up a flow, you can take a try with the screenshots below to see if it helps.

    Here are my two lists.

    vLilyWmsft_1-1635481654853.png

    vLilyWmsft_0-1635481640312.png

    Flow in details.

    vLilyWmsft_10-1635482265586.png

    vLilyWmsft_3-1635481699620.png

    Expression:

    union(array(items('Apply_to_each')?['Title']),variables('Title'))

    vLilyWmsft_4-1635481740761.png

    vLilyWmsft_11-1635482435870.png

    Expression:

    int(items('Apply_to_each_3')?['QuantityUsed'])

    vLilyWmsft_6-1635481956178.png

    vLilyWmsft_7-1635482050248.png

    vLilyWmsft_8-1635482115246.png

    Save and test the flow.

    vLilyWmsft_12-1635482659584.png

    vLilyWmsft_13-1635482674251.png

    After flow runs, List A will be update like below.

    vLilyWmsft_9-1635482197329.png

    Hope the content above may help you.

    Best Regards

    If my solution helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • cd-lyst Profile Picture
    4 on at

    Hello, thank you for the post. I am trying to complete something very similar but am struggling to get past the finish line.

     

    cdlyst_0-1667320029900.png

     

    Please disregard, it looks like I fixed it! 🙂

     

  • Juan2004 Profile Picture
    8 on at

    Hello, I'm having the same problem that you had. How did you manage to fix it? 

    Thanks. 

    -Juan

  • cd-lyst Profile Picture
    4 on at

    In my SharePoint list, I'm using a decimal number so I have to use FLOAT here in Power Automate. The post says to use INT but that isn't compatible with decimals, which is why Compose 2 was throwing the error.

     

    cdlyst_0-1668639914211.png

    cdlyst_1-1668639924085.png

    Not sure if this helps but I had to add a few helper columns in the SP list to get the proper columns updated (i.e. run a calculated column and have it be updated to a text/number column in the same Flow).

  • newbiepowernow Profile Picture
    2 on at

    hi, can you kindly clarify what are the Title's in the first Compose expression? 

    union(array(items('Apply_to_each')?['Title']),variables('Title'))

  • cd-analyst Profile Picture
    2 on at

    Hello, this is just a variable that you create earlier in the steps.

     

    cdanalyst_0-1681227996565.png

     

  • FredCongo Profile Picture
    2 on at

    Hello, I tryied this exemple 

    But the update for 'apply to each 4' is not working.

    Someone can tell me why ? 

    FredCongo_0-1693164004460.png

     

  • Suggested answer
    Ellis Karim Profile Picture
    11,681 Super User 2025 Season 2 on at
    Here is an alternative method for summing the values of an array using XML:
     
    ​​​​​​​
     
    Expressions used in the flow:
     
    {
      "root": {
        "number": @{body('Select')}
      }
    }
    
    
    xpath(xml(outputs('Compose_JSON')), 'sum(/root/number)')
     
     
     
    For more information on this method see : Instantly sum an array with Power Automate (tachytelic.net)
     
     
    Ellis
     
  • trice602 Profile Picture
    15,402 Super User 2025 Season 2 on at
    I also like the xpath approach here and is also a viable solution.  Tom
  • Suggested answer
    Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at
    Just one expression using xpath:
    From: @{outputs('ListA')}
    Map:
    addProperty(
    	item(),
    	'QuantityUsed',
    	xpath(
    		xml(json(concat('{"Root":{"Item":', outputs('ListB'), '}}'))),
    		concat('sum(//Item[Title="', item()['Title'], '"]/QuantityUsed)')
    	)
    )

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard