cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sadingle
Frequent Visitor

Comparing SharePoint list against Excel table and updating a second list based on the values only found in the Excel table

I'm trying to build a flow so I'll start with the basics:

  1. Flow detects a change in an Excel file in a document library
  2. Deletes data from SP List 1
  3. Appends data from Excel into SP List 1

 

Once that works, now I need to be more selective.  There will be two columns in the SP list, that are not in the Excel file that contain data that we will edit via a Power App.  We need to preserve this data while updating the data in the list.  So modify steps 2 and 3 of the flow to do the following:

 

Now add a layer of complication

Goal: Create two loops in the flow that adds and delete records.  The purpose of this is to be able to keep the data that’s already been entered for an employee while removing old employees (not in the Excel file) and adding new employees (not in the SP List).

 

  1. Loop through each record in the Excel file (New) and compare Personnel Numbers (the key field) to the SP List 1 (Old).  If the Personnel Number does not exist in the SP List 1 (Old): Add it to the SP List 1.
  2. Loop through each record in the SP List 1 (Old) and compare Personnel Numbers to the Excel file (New).  If the Personnel Number does not exist in the Excel file: Delete it from the SP List 1.

 

I just had it comparing SP List 1 with the Excel sheet and adding the rows that are in both to SP List 2, but I'm having some trouble. Just let me know if there are any questions or recommendations. Pictures are attached but I can explain each step if needed.

 

Thanks everyone!

14 REPLIES 14
SamLed
Super User
Super User

Hi,

 

May I propose something to improve your flow:

1° Get all data from Excel and from SP List

2° Compare both array to get missing personal numbers in SP List. You get new employees to create in SP list. Loop on filter results to create items.

3° Compare again to get missing personal numbers in Excel. You get employees to remove from SP list. Loop on filter results to remove items.

 

Here is how to achieve such comparison: List values missing in an array using Power Automate (tomriha.com)

 

[Edit] Here a flow to illustrate:

 

The trigger is configured to monitor only a specific directory, so it is focused on the modification of the single file present which is your input Excel file, then:

 

1° Fetch source file data and target list data:

 

SamLed_0-1691976661082.png

 

2° Get "Personal Number" arrays from both sources:

 

SamLed_1-1691977393146.png

 

3° Filter array to get employees to create (items missing from list but present in file) and to get employees to delete (items present in list from missing from file), run flow and keep both filter actions outputs, they will be useful to generate JSON schemas later:

 

SamLed_5-1691998464891.png

 

4° For each employee to add to list, filter Excel file rows output to get current employee's one, parse JSON and create new item in list.  "Filter array" action will return an array with one matching item. To avoid having to deal an useless "Apply to each" in the next step, generate the schema of "Parse JSON" action from output of "Filter Array - Invite Employees to Create" taking only one item of array and set its content with first item of array using"first()" expression:

 

SamLed_3-1691997887693.png

 

5° For each employee to remove from list, filter list output to get current employee's one, parse JSON and delete item from list.  Same trick as above, "Filter array" action will return an array with one matching item, generate the schema of "Parse JSON" action from output of "Filter Array - Invite Employees to delete" taking only one item of array and set its content with first item of array using"first()" expression:

 

SamLed_4-1691998289133.png

 

______________________________________________________________

If I have answered your question, please Accept the post as solution.
If you like my response, please Thumbs Up.

 

 

 

SamLed
Super User
Super User

Hi,

 

Edited my answer to add a flow to illustrate.

______________________________________________________________

If I have answered your question, please Accept the post as solution.
If you like my response, please Thumbs Up.

Thank you so much, however, I am unsure of what I should write in the required "Schema" sections.

Also, my filter array is only pulling the first column values, not the column headers.  

sadingle_0-1692031486766.png

 

I also have multiple columns in the lists and excel table that are all matching 

SamLed
Super User
Super User

Hi, 

 

About your both Parse JSON schema, use the "Generate from sample" button and past outputs body of precedent action (Filter array) which is an array with one item, but take only the item, ignore square brackets, see in my flow:

 

SamLed_1-1692129668334.png

About your last reply, I don't get what you're tell me, the ID (Personal Number) should be the only reference on which you check match.

______________________________________________________________

If I have answered your question, please Accept the post as solution.
If you like my response, please Thumbs Up.

 

 

 

sadingle
Frequent Visitor

That helps, but the output of my filter arrays are just lists of the value from the Personnel Num fields. Please advise because I have no clue why.

sadingle_0-1692248153610.pngsadingle_1-1692248240644.png

 

SamLed
Super User
Super User

That's not "Filter array" but "Select" you are showing me, that's normal this actions returns only "Personal number" that's the trick to be able to compare both arrays and extract only missing items.

 

Please, look at my first answer and tell me what is not clear, you have just to follow it step by step.

______________________________________________________________

If I have answered your question, please Accept the post as solution.
If you like my response, please Thumbs Up.

Thank you for all of your help, and I apologize for my ignorance.

 

This is the issue now; I can delete from the old SP list because the "ID" matches, but when it tries to delete from the new SP list it errors out saying item not found.  Any thoughts?

 

 

sadingle_1-1692370747732.png

 

SamLed
Super User
Super User

Don't apologize for that, we all ignore something, there is no stupid question.

 

Ok, are you using same ID for both List ?

If so, it can't work that way, both items are in different list so may have different Id.

______________________________________________________________

If I have answered your question, please Accept the post as solution.
If you like my response, please Thumbs Up.

thanks for being understanding!

 

But no, the ID for each record is different between each sharepoint list. However, the column names and row contents are exactly the same.  So they are identical except for the fact that the "ID" for each record is different.

 

I was trying to figure out a way to "get items" from the new sharepoint list where the "Personnel Num" (primary key column) from the "Filter array: get employee to delete" matches the "Personnel Num" from the new sharepoint list and then delete it.

 

Is that possible?

SamLed
Super User
Super User

Hi,

 

Yes, it can easely be done by using a "Get items" and filter query:

SamLed_1-1692453414548.png

 

Where:

[Field internal name] is the internal name of your personal number field

[value] is the personal number dynamic content or variable from previous steps. If your field is not type number surround it with quotes '.

 

To get field internal name, go to your list setting, click on column to edit it and look at the end of URL:

SamLed_2-1692453606775.png

 

[Edit] Get items returns an array, even if there is only one item, so use this expression to get item ID without having an Apply to each appearing: body('Get_items')[0]['ID']

______________________________________________________________

If I have answered your question, please Accept the post as solution.
If you like my response, please Thumbs Up.

 

QSSCC
Frequent Visitor

I keep getting null in the Filter Array just before the Parse JSON.

 

I am using a dynamically named excel file, and the input is correct.

 

Also, your instructions mention an "Invite Employees to Create" but it is missing from your flow, and you have 2 

QSSCC
Frequent Visitor

This is still creating duplicates of items on my SharePoint List. The Output of the first create filter contains some of the input, even though I have it set to "does not contain". To be clear, I am trying to add 100-150 items, not just one. The first time I run it, 124ish items are added (checking against the input it is complete), but the second time I run it with the same Excel sheet it adds a copy of 58 of the items.

Helpful resources

Announcements

Update! June 13th, Community Ambassador Call for User Group Leaders and Super Users

Calling all Super Users & User Group Leaders   UPDATE:  We just wrapped up June's Community Ambassador monthly calls for Super Users and User Group Leaders. We had a fantastic call with lots of engagement. We are excited to share some highlights with you!    Big THANK YOU to our special guest Thomas Verhasselt, from the Copilot Studio Product Team for sharing how to use Power Platform Templates to achieve next generation growth.     A few key takeaways: Copilot Studio Cookbook Challenge:  Week 1 results are posted, Keep up the great work!Summer of Solutions:  Starting on Monday, June 17th. Just by providing solutions in the community, you can be entered to win tickets to Power Platform Community Conference.Super User Season 2: Coming SoonAll communities moving to the new platform end of July We also honored two different community members during the call, Mohamed Amine Mahmoudi and Markus Franz! We are thankful for both leaders' contributions and engagement with their respective communities. 🎉   Be sure to mark your calendars and register for the meeting on July 11th and stay up to date on all of the changes that are coming. Check out the Super User Forum boards for details.   We're excited to connect with you and continue building a stronger community together.   See you at the call!

Copilot Cookbook Challenge | Week 2 Results | Win Tickets to the Power Platform Conference

We are excited to announce the "The Copilot Cookbook Community Challenge is a great way to showcase your creativity and connect with others. Plus, you could win tickets to the Power Platform Community Conference in Las Vegas in September 2024 as an amazing bonus.   Two ways to enter: 1. Copilot Studio Cookbook Gallery:  https://aka.ms/CS_Copilot_Cookbook_Challenge 2. Power Apps Copilot Cookbook Gallery: https://aka.ms/PA_Copilot_Cookbook_Challenge   There will be 5 chances to qualify for the final drawing: Early Bird Entries: March 1 - June 2Week 1: June 3 - June 9Week 2: June 10 - June 16Week 3: June 17 - June 23Week 4: June 24 - June 30     At the end of each week, we will draw 5 random names from every user who has posted a qualifying Copilot Studio template, sample or demo in the Copilot Studio Cookbook or a qualifying Power Apps Copilot sample or demo in the Power Apps Copilot Cookbook. Users who are not drawn in a given week will be added to the pool for the next week. Users can qualify more than once, but no more than once per week. Four winners will be drawn at random from the total qualifying entrants. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once. If they are drawn multiple times, another user will be drawn at random. Prizes:  One Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value, does not include travel, lodging, or any other expenses) Winners are also eligible to do a 10-minute presentation of their demo or solution in a community solutions showcase at the event. To qualify for the drawing, templates, samples or demos must be related to Copilot Studio or a Copilot feature of Power Apps, Power Automate, or Power Pages, and must demonstrate or solve a complete unique and useful business or technical problem. Power Automate and Power Pagers posts should be added to the Power Apps Cookbook. Final determination of qualifying entries is at the sole discretion of Microsoft. Weekly updates and the Final random winners will be posted in the News & Announcements section in the communities on July 29th, 2024. Did you submit entries early?  Early Bird Entries March 1 - June 2:  If you posted something in the "early bird" time frame complete this form: https://aka.ms/Copilot_Challenge_EarlyBirds if you would like to be entered in the 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. Copilot Cookbook Gallery:Power Apps Cookbook Gallery:1.  @Mathieu_Paris 1.   @SpongYe 2.  @Dhanush 2.   @Deenuji 3.  n/a3.   @Nived_Nambiar  4.  n/a4.   @ManishSolanki 5.  n/a5.    n/a   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. Copilot Cookbook Gallery:Power Apps Cookbook Gallery:1. Kasun_Pathirana1. ManishSolanki2. cloudatica2. madlad3. n/a3. SpongYe4. n/a4. n/a5. n/a5. n/a

Win free tickets to the Power Platform Conference | Summer of Solutions

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**

Celebrating the June Super User of the Month: Markus Franz

Markus Franz is a phenomenal contributor to the Power Apps Community. Super Users like Markus inspire others through their example, encouragement, and active participation.    The Why: "I do this to help others achieve what they are trying to do. As a total beginner back then without IT background I know how overwhelming things can be, so I decided to jump in and help others. I also do this to keep progressing and learning myself." Thank you, Markus Franz, for your outstanding work! Keep inspiring others and making a difference in the community! 🎉  Keep up the fantastic work! 👏👏 Markus Franz | LinkedIn  Power Apps: mmbr1606  

Your Moment to Shine: 2024 PPCC’s Got Power Awards Show

For the third year, we invite you, our talented community members, to participate in the grand 2024 Power Platform Community Conference's Got Power Awards. This event is your opportunity to showcase solutions that make a significant business impact, highlight extensive use of Power Platform products, demonstrate good governance, or tell an inspirational story. Share your success stories, inspire your peers, and show off some hidden talents.  This is your time to shine and bring your creations into the spotlight!  Make your mark, inspire others and leave a lasting impression. Sign up today for a chance to showcase your solution and win the coveted 2024 PPCC’s Got Power Award. This year we have three categories for you to participate in: Technical Solution Demo, Storytelling, and Hidden Talent.      The Technical solution demo category showcases your applications, automated workflows, copilot agentic experiences, web pages, AI capabilities, dashboards, and/or more. We want to see your most impactful Power Platform solutions!  The Storytelling category is where you can share your inspiring story, and the Hidden Talent category is where your talents (such as singing, dancing, jump roping, etc.) can shine! Submission Details:  Fill out the submission form https://aka.ms/PPCCGotPowerSignup by July 12th with details and a 2–5-minute video showcasing your Solution impact. (Please let us know you're coming to PPCC, too!)After review by a panel of Microsoft judges, the top storytellers will be invited to present a virtual demo presentation to the judges during early August. You’ll be notified soon after if you have been selected as a finalist to share your story live at PPCC’s Got Power!  The live show will feature the solution demos and storytelling talents of the top contestants, winner announcements, and the opportunity to network with your community.  It's not just a showcase for technical talent and storytelling showmanship, show it's a golden opportunity to make connections and celebrate our Community together! Let's make this a memorable event! See you there!   Mark your calendars! Date and Time: Thursday, Sept 19th Location: PPCC24 at the MGM Grand, Las Vegas, NV 

Tuesday Tip | Accepting Solutions

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   To enhance our collaborative environment, it's important to acknowledge when your question has been answered satisfactorily. Here's a quick guide on how to accept a solution to your questions: Find the Helpful Reply: Navigate to the reply that has effectively answered your question.Accept as Solution: Look for the "Accept as Solution" button or link, usually located at the bottom of the reply.Confirm Your Selection: Clicking this button may prompt you for confirmation. Go ahead and confirm that this is indeed the solution.Acknowledgment: Once accepted, the reply will be highlighted, and the original post will be marked as "Solved". This helps other community members find the same solution quickly. By marking a reply as an accepted solution, you not only thank the person who helped you but also make it easier for others with similar questions to find answers. Let's continue to support each other by recognizing helpful contributions. 

Users online (2,124)