cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
carudev
Advocate II
Advocate II

How to compare an ID from excel file with an entire sharepoint list?

Hello guys!

 

I have a list on Sharepoint where I need to update it with a new list.

It basically works like this: I take the ID that I have in excel from a new list and compare it with the ID that is already there in the Sharepoint.
Example:

If  IDExcel = IDSharepoint, update item. And so far it works very well!

 

But there is the case that: If there is no IDExcel within the Sharepoint list, create a new item. And this case is not working. Look at how I'm trying to do:

 

EXAMPLE=   

IDExcel = "123456", and I want to know if this IDExcel exists within the Sharepoint list.

 

carudev_1-1617819843134.png

 

carudev_0-1617819576472.png

 

  • Translate images: "Não contem" is like "Doesn't contain", and "Saidas" is like "Outputs". 

 

Value is the output of "Get Items", and I want to check if there is an ID inside the Value.

It doesn't have to be done exactly that way, but that's what I've managed to think so far.

 

Look at the IDLinha field inside the Value, this is what I need to use to compare::::::

carudev_2-1617819952567.png

 


So what I need is: check if an ID exists within my Sharepoint list and if it does not exist, create an item. But this comparison is not working, any ideas?

 

THANK YOU!!!

1 ACCEPTED SOLUTION

Accepted Solutions

Your approach will not work because you are comparing the "Value" element from the get items action which is an array of objects. What you need is an array of IDs from SharePoint which will make your comparison work. You can do it with a select action like this:

2021-04-08_07-04-47.gif

This will produce you a clean array of IDs, which will look something like this:

[
  1,
  2,
  3
]

You can then easily do your comparison:

2021-04-08_07-09-50.png

Does that make sense?

View solution in original post

20 REPLIES 20

What does "Nao Contem" (forgive the lack of accents) mean? Does Not Contain? 
Can you hover over the Data Operation "Saidas" and paste what the function is? (or type it out) 
I ran into a similar situation where FOO contained data but the function kept evaluating as NULL. 
The dynamic value had something like triggerbody()?['body']?['next']?['what_I_Wanted']  My fix was to manually type in the function and trim body so it was triggerbody()?['next']?['what_I_Wanted']

I get the feeling from your screenshots you are experiencing something similar......

"Não contem" is like "Doesn't contain", and "Saidas" is like "Outputs". 

And this "Saidas" / "Outputs" is my ID that I extracted from excel. I want to update the list on Sharepoint with an excel. 

Then I compare the excel ID with that of the Sharepoint. This happens daily, whenever this excel comes to me by email I take it and use it to update the list on Sharepoint.

Currently, my suspicion is inside the Saidas.
If you do a test run, and then show the raw outputs of when that Saidas is first generated? Can you also show the output of the evaluation step? 
I'm convinced it's something in either 
1. the first time you engaged this Data Operation (Saidas)
OR
2. It's in the evaluation itself (if you can hover over that Saidas and type out or screengrab how it formatted itself) 

@carudev    hi, i think you may need to change your condition.   it sounds like you need to check if your 'IDExcel' is empty, yes?  If so, I believe you can just select the 'IDExcel' field and check if it is equal to "null".

 

ETA:  instead of 'value,'  you can either do a Parse JSON action ahead and directly select the IDLinha field by copying and pasting the output of your Get Items action into the sample JSON of the parse JSON action.  Or you can write an expression:  body('get_items')?['IDLinha']

vikulkar
Community Support
Community Support

Hi @carudev ,

 

Please try the condition: 

length(outputs('Get_items')?['body/value']) and compare it with 0

Carudev.PNG

 

If it is 0 then a new item can be created.

 

Thanks and Regards,

  Vikas K

@carudev The length approach might actually be easier. If it comes back 0 then it's pretty much the same result as "not contain". 

NorthernChuck_0-1617824990400.png

In your original condition, this is what I'm after (should you chose to pursue a text comparison). 
May the Force be With You @carudev and Good Luck 🙂

carudev
Advocate II
Advocate II

Guys, actually I need to compare it like this:


The Excel ID I already have its value.

 

For example:

 

IDExcel = "1234567"

 

Then I want to know if the IDSharepoint, which is inside the Value of GetItems, is the same as the IDExcel.

 

This is my IDExcel:

 

carudev_0-1617825295733.png

 

And I want to compare it with this sharepoint list:

 

carudev_1-1617825343778.png

 

So if there is no IDLinha = IDExcel in my Sharepoint list, then I create the item. Because I'm checking if the item already exists in the sharepoint or not.

No, I want to know if the IDExcel exists within the Sharepoint list, if it does not exist, create a new item. So I need to compare the IDs.

carudev_2-1617825638207.png

 

This is my Saidas, it is the excel id that I want to compare. 

vikulkar
Community Support
Community Support

@carudev ,

are you not leveraging the FilterQuery in your GetItems action?

vikulkar_0-1617825913980.png

it should be something like:

 

IDSharepoint eq '10336821'

@carudev I'm following your logic. I trust that the data is there (or in this case not there). What I'm trying to help with is the evaluation. I'd really like to see the actual output of your evaluation of Value Nao Contem Saidas   I'm convinced it's something there. 

If not, can you provide some sample data with 1 or 2 rows (records)? This way I can test as well. I once had a select that needed me to manually write out item() function with the array index number of 0. I find when things like evaluations don't work it's because of the expression....... 

NorthernChuck_0-1617826099481.png

 

carudev
Advocate II
Advocate II

My flow works like this:

Every day I receive an email with an excel file, so I get this excel and "ForEach" line inside it I compare it with the lines there in the Sharepoint list, if the file ID is the same as the ID in the Sharepoint list, I update it the item. And it works well, as I compare item by item using the ForEach ID on Sharepoint. 

 

So now I need to deal with cases where the item in the file does not exist in the sharepoint. So I take the IDExcel that came in the file and check if that ID already exists or not in Sharepoint, because if it does not exist I will create it there in the Sharepoint list.

 

Below more details of my flow:

 

I use Get Items, then I use a For Each to work with the lines in the file, split them up and do a series of treatments on the lines:

carudev_0-1617826703881.png

 

And then I compare the line ID of the file with all the lines in the Sharepoint:

 

carudev_1-1617826911398.png

 

Value comes from Get Items, and this is its content of Value:

 

carudev_2-1617827058795.png

 

And the "Saidas" is this: that is the ID that I already have - it was extracted from the excel file - and I want to know if it already exists or not in Sharepoint.

 

carudev_3-1617827165540.png

 

 

Thank you guys! Sorry for the terrible English, but I think now I have better explained my problem. Thank you!

No worries @carudev !! 🙂 We will get to the bottom of this elusive evaluation. 
Unfortunately I am out for the day, but I will review your post either later this evening or tomorrow morning!

Cheers, 
~C

So, the easiest way for me to help you is to try and recreate myself. I'll gladly help, but your sample data is in a picture format and it's rather large. Can you paste me in text that sample payload (replace things like Display Name: Kermit Frog, Email: kermit@frog.com - I just need sample data to reproduce) 

#2 @vikulkar is very correct in their suggestion. Filtering using an Odata query would accomplish what you are looking for. If you had to, you could load the file more than once and then have more than one singular Odata filter to match up with your "series of treatments"

Anonymous
Not applicable

I am having the exact same issue myself ... trying to compare an ID column in a SharePoint list to the ID column in a .csv file. If the Excel ID exists in the SPO list, update that list item with the data in the .csv file. Otherwise, create a new SPO list item and populate with .csv data. 

 

I was following along with a YouTube tutorial (Power Automate - Bulk Add Excel data to SharePoint list), but the OData filter query isn't working for me. I was using:  LMSEnrollmentID eq 'ID' in the SharePoint Get Items action, where LMSEnrollmentID is a column in the SPO list and ID is a column in the .csv file. I'll be following this thread to see how it works out! 

 

 

 

 

Your approach will not work because you are comparing the "Value" element from the get items action which is an array of objects. What you need is an array of IDs from SharePoint which will make your comparison work. You can do it with a select action like this:

2021-04-08_07-04-47.gif

This will produce you a clean array of IDs, which will look something like this:

[
  1,
  2,
  3
]

You can then easily do your comparison:

2021-04-08_07-09-50.png

Does that make sense?

That makes sense to me. It would explain why the comparison wasn't working. Of all the small itches I have with PowerAutomate, I miss having a shell that provides feedback the most! Kudos on the excellent reply with a gif animation!

OMG!!!!!! IT WORKED!!! THANK YOU SO MUCH @Paulie78 . OMG!!

I WAS ALREADY LOST WITHOUT KNOWING HOW TO MAKE THIS WORK, THANK YOU SO MUCH!!!!!

WOOHOO OMG! NO PROBLEM AT ALL, MY PLEASURE! 😂🤣

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 (843)