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
Paulie78
Super User
Super User

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
NorthernChuck
Advocate II
Advocate II

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) 

illmatic
Helper IV
Helper IV

@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"

Shelly-S
Frequent Visitor

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! 

 

 

 

 

Paulie78
Super User
Super User

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?

NorthernChuck
Advocate II
Advocate II

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

Paulie78
Super User
Super User

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

Helpful resources

Announcements

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!    

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS   Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!   Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!       Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!   UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!   European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!     Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!     For more events, click the image below to visit the Microsoft Community Days website.      

Tuesday Tip | Update Your Community Profile Today!

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.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!

Users online (3,795)