cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Count total of items per country in one list then update total to another column in another list

I am trying to create a flow that will count the total of items per site/country in List A then populate in List B the total returned in another column for that specific site/country.  Example: count total of staff against London in List A then populate in List B the total. And i need the flow to run every time there is a change to the number of staff in List A for that particular location.

 

Please help!

1 ACCEPTED SOLUTION

Accepted Solutions

hello there sorry. I tried to export and import the flow to my other dev tenant, but it is failing. Not sure if this is because of recent updates from Power Automate or some policy in my other dev tenant. How ever i have taken extra steps and tried creating step by step. I have followed the same instructions during the document creation and it is giving me expected output. Can you please refer to the Git hub repo share your feedback? 

https://github.com/vayinapurapu/UpdatingListProperties/blob/main/Updating%20list%20properties_Step_B... 

View solution in original post

20 REPLIES 20

Can you try the following steps?

1) Create a flow with trigger on item created or modified

2) Use SharePoint Get Items from List A and store the count in variable

3) Update the value of count in list B using update item action

Couple of points to consider, Make sure the flow is not running under infinite loop, use proper condition to trigger

https://www.youtube.com/watch?v=oKN4_5o2NUA&t=40s

Also Get items by default gets top 100 records. If the items are less than 5000 you can either use pagination. Below is the video that gives more insights

https://www.youtube.com/watch?v=X-urscD106Y

hope this helps.

 

Cheers,

Vinay.  

Hi Vinay

Screenshot 2022-08-22 155923.png

thanks for the help here. On Step 2- store the count in variable: can you explain a bit more? And on Step 3 i assume i will use the variable dynamic content in the column i need the total updated in...

 

attached screenshot is how far i have got.

Hi Vinay, have you had any thoughts on this?

Update the request count

Introduction: In this article, we will go through how to update the list column based on requests on other lists. Here I have 2 lists one is requests and other is countries.

In the requests list ‘Country’ is a look up column.

vayinapurapu1_0-1661924852921.png

 

vayinapurapu1_1-1661924852928.png

 

Here the property ‘RequestCount’ contains the count of requests based on ‘Requests’ list.

Flow Design:

Now we will go through the steps of designing the flow.

Step 1:

Login to Power Automate portal (https://make.powerautomate.com) with your organization account.

Step 2:

Select the trigger point as SharePoint and select ‘On item created or modified’.

vayinapurapu1_2-1661924852939.png

 

Step 3: Get items from the countries list.

vayinapurapu1_3-1661924852953.png

 

Step 4: From the countries list we need ID and the Country names. These are needed to update the list item properties. Here create the JSON object using the ‘Select’ data operation.

vayinapurapu1_4-1661924852982.png

 

  • From: property is dynamic property ‘value’ from the ‘Get items – Countries’ action.
  • Map:
    • Here since we need JSON object enter the first key as ID, and values as item()?[‘ID’]
    • Enter the other key as ‘Country’ and the value is item()?[‘Title’]

 

Step 5: create ‘Apply to Each’ and inside add ‘compose’ action and log the current item. At first we will get the country value from the current json object.

vayinapurapu1_5-1661924852985.png

 

Step 6: Now add ‘Get Items’ and configure the action to get the requests that satisfies the filter query where the current item country equals the country property of the requests.

vayinapurapu1_6-1661924853003.png

 

In the filter query I have updated the property as Country/Title, since country is look up column and it requires specific format to check the filter. More about the OData can be found in references section.

And the value is the dynamic outputs of compose action log current item.

Step 7: Now here I am getting the length of collection and checking if the count greater than or equal to 1.

vayinapurapu1_7-1661924853009.png

 

length(outputs('Get_items-Requests')?['body/value'])

 

Step 8: If the collection has value and go ahead update item with Request count.

vayinapurapu1_8-1661924853018.png

 

  • For update item we need ID, Title properties
  • For ID: this is expression where you need to select ID from the current item of apply to each loop.

               

vayinapurapu1_9-1661924853022.png

 

  • Same thing applies for country.

           

vayinapurapu1_16-1661925216102.png

 

 

 

  • Request Count: Update the with expression length of collection from Get items action.

   

vayinapurapu1_17-1661925242187.png

 

 

 

vayinapurapu1_12-1661924853056.png

 

Step 9: Below is the complete flow and it should similar to below.

vayinapurapu1_13-1661924853063.png

 

please note that you may have to avoid infinite loops if you are using trigger on item created or modified. Refer to the article in references. 

References:

https://www.youtube.com/watch?v=yeAnuTB85eg

 

Stopping Infinite Loops When Updating SharePoint List Items – Scott J Shearer – M365 and Power Platf...

 

@LearnDayByDay does this meet your needs? Please let me know.

Hi, i am going to try this solution today. I will update you with my results 🙂 thank you so much!

im stuck on Step 5. see screenshot..i cannot get the inputs you show on your example from previous step. What goes in the Apply to Each Output?

LearnDayByDay_0-1662666828162.png

 

Can you try the below post. I have also updated the flow in this post

Updating List Properties Using Flow (c-sharpcorner.com)

Hope this helps. 

Hi Vayina

 

i have tried following your steps a couple of times using my current Lists and creating lists from new and i cannot replicate what you have shown here. The Step By Step you have provided does not mirror the Step 9 of what the finished flow should look like.

I am unable to get the Input of Country as shown in Step 5, also on Step 8 the ID and Title field does not give me the 'ID' and 'Country' expression to pick from under the dynamic content.

 

Happy to organise a Teams meeting to go over it if you are willing?

did you try adding 'Apply to each' action at step 5? Then add the compose action as shown in the steps. 

vayinapurapu1_1-1663650869151.png

 

for the section 'Select an ouput from previous stage' please select the dynamic output from the select Country Names compose action. Please let me know how it goes or for any further questions. 

 

Thanks,

 

Vinay. 

 

i have, this is what i get:

LearnDayByDay_1-1663672233523.png

 

 

i have followed the Steps exactly how you typed it and my flow looks different to yours:

LearnDayByDay_0-1663682332013.png

If you can, please let me know if we can arrange a Teams or Whatsapp call to go over this.

You are very close. Can you please follow from Step 6? You still need to configure couple of actions inside apply to each

Updating List Properties Using Flow (c-sharpcorner.com)

Inside apply to each, you need to select the 'Outputs' of country names

For each country name, filter the 'Requests' list using filter query 

vayinapurapu1_0-1664254931750.png

If the length of the collection is greater than or equal to 1, then update the item in 'Countries' list. 

vayinapurapu1_1-1664255068976.pngvayinapurapu1_2-1664255084456.png

 

I have also updated the flow in Github. Can you please try downloading it and check. You should be able to figure it out. If still get stuck Please let me know. 

vayinapurapu/UpdatingListProperties (github.com) 

 

Hope this helps. 

 

Hi, so the Github download helped get further-Thank you!!

 however, i am getting this error: 

LearnDayByDay_0-1665400933410.png

Does the Country Column in the Requests list have to be renamed from Title to Country? i have created the list exactly how you have it though.

LearnDayByDay_1-1665401013234.png

 

 

 Can you please check this 7 minute video i did it. https://youtu.be/LIRQrXFjNW8?

 

have you defined the filter query as mentioned in below screen shot? 

vayinapurapu1_0-1665629620512.png

 

You are almost close. I have explained the filter query in the video.

Hope this helps.

 

Thanks,

 

Vinay. 

 

Hi VInay

I changed the column 'Country' in the Requests list to a look up which i never had before.

 

Still getting the same error that the column 'Country' does not exist:  Column 'Country' does not exist. It may have been deleted by another user.

hello there sorry. I tried to export and import the flow to my other dev tenant, but it is failing. Not sure if this is because of recent updates from Power Automate or some policy in my other dev tenant. How ever i have taken extra steps and tried creating step by step. I have followed the same instructions during the document creation and it is giving me expected output. Can you please refer to the Git hub repo share your feedback? 

https://github.com/vayinapurapu/UpdatingListProperties/blob/main/Updating%20list%20properties_Step_B... 

And finally we have done it!!! Thank you so much for all the patience and tutorials, step by step!

i changed the column 'Country' right at the start with 'Country1' so that is why it was always coming up with Column Country was not found 😙

Thank you so much for all the help on this request, now i just need to apply it to my actual Lists 🙂

Glad we have made it finally!! Appreciated. Would you mind accepting my thread that helped for you 'As a solution'? 

 

Cheers,

Vinay. 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (487)