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

Exclusive LIVE Community Event: Power Apps Copilot Coffee Chat with Copilot Studio Product Team

It's time for the SECOND Power Apps Copilot Coffee Chat featuring the Copilot Studio product team, which will be held LIVE on April 3, 2024 at 9:30 AM Pacific Daylight Time (PDT).     This is an incredible opportunity to connect with members of the Copilot Studio product team and ask them anything about Copilot Studio. We'll share our special guests with you shortly--but we want to encourage to mark your calendars now because you will not want to miss the conversation.   This live event will give you the unique opportunity to learn more about Copilot Studio plans, where we’ll focus, and get insight into upcoming features. We’re looking forward to hearing from the community, so bring your questions!   TO GET ACCESS TO THIS EXCLUSIVE AMA: Kudo this post to reserve your spot! Reserve your spot now by kudoing this post.  Reservations will be prioritized on when your kudo for the post comes through, so don't wait! Click that "kudo button" today.   Invitations will be sent on April 2nd.Users posting Kudos after April 2nd at 9AM PDT may not receive an invitation but will be able to view the session online after conclusion of the event. Give your "kudo" today and mark your calendars for April 3, 2024 at 9:30 AM PDT and join us for an engaging and informative session!

Tuesday Tip: Unlocking Community Achievements and Earning Badges

TUESDAY TIPS are our way of communicating helpful things we've learned or shared that have helped members of the Community. Whether you're just getting started or you're a seasoned pro, Tuesday Tips will help you know where to go, what to look for, and navigate your way through the ever-growing--and ever-changing--world of the Power Platform Community! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!     THIS WEEK'S TIP: Unlocking Achievements and Earning BadgesAcross the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. These badges each signify a different achievement--and all of those achievements are available to any Community member! If you're a seasoned pro or just getting started, you too can earn badges for the great work you do. Check out some details on Community badges below--and find out more in the detailed link at the end of the article!       A Diverse Range of Badges to Collect The badges you can earn in the Community cover a wide array of activities, including: Kudos Received: Acknowledges the number of times a user’s post has been appreciated with a “Kudo.”Kudos Given: Highlights the user’s generosity in recognizing others’ contributions.Topics Created: Tracks the number of discussions initiated by a user.Solutions Provided: Celebrates the instances where a user’s response is marked as the correct solution.Reply: Counts the number of times a user has engaged with community discussions.Blog Contributor: Honors those who contribute valuable content and are invited to write for the community blog.       A Community Evolving Together Badges are not only a great way to recognize outstanding contributions of our amazing Community members--they are also a way to continue fostering a collaborative and supportive environment. As you continue to share your knowledge and assist each other these badges serve as a visual representation of your valuable contributions.   Find out more about badges in these Community Support pages in each Community: All About Community Badges - Power Apps CommunityAll About Community Badges - Power Automate CommunityAll About Community Badges - Copilot Studio CommunityAll About Community Badges - Power Pages Community

Tuesday Tips: Powering Up Your Community Profile

TUESDAY TIPS are our way of communicating helpful things we've learned or shared that have helped members of the Community. Whether you're just getting started or you're a seasoned pro, Tuesday Tips will help you know where to go, what to look for, and navigate your way through the ever-growing--and ever-changing--world of the Power Platform Community! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!   This Week's Tip: Power Up Your Profile!  🚀 It's where every Community member gets their start, and it's essential that you keep it updated! Your Community User Profile is how you're able to get messages, post solutions, ask questions--and as you rank up, it's where your badges will appear and how you'll be known when you start blogging in the Community Blog. 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.     Password Puzzles? No Problem! Find out how to sync your Azure AD password with your community account, ensuring a seamless sign-in. No separate passwords to remember! Job Jumps & Email Swaps Changed jobs? Got a new email? Fear not! You'll find out how to link your shiny new email to your existing community account, keeping your contributions and connections intact. Username Uncertainties Unraveled Picking the perfect username is crucial--and sometimes the original choice you signed up with doesn't fit as well as you may have thought. There's a quick way to request an update here--but remember, your username is your community identity, so choose wisely. "Need Admin Approval" Warning Window? If you see this error message while using the community, don't worry. A simple process will help you get where you need to go. If you still need assistance, find out how to contact your Community Support team. Whatever you're looking for, when it comes to your profile, the Community Account Support Knowledge Base article is your treasure trove of tips as you navigate the nuances of your Community Profile. It’s the ultimate resource for keeping your digital identity in tip-top shape while engaging with the Power Platform Community. So, dive in and power up your profile today!  💪🚀   Community Account Support | Power Apps Community Account Support | Power AutomateCommunity Account Support | Copilot Studio  Community Account Support | Power Pages

Super User of the Month | Chris Piasecki

In our 2nd installment of this new ongoing feature in the Community, we're thrilled to announce that Chris Piasecki is our Super User of the Month for March 2024. If you've been in the Community for a while, we're sure you've seen a comment or marked one of Chris' helpful tips as a solution--he's been a Super User for SEVEN consecutive seasons!   Since authoring his first reply in April 2020 to his most recent achievement organizing the Canadian Power Platform Summit this month, Chris has helped countless Community members with his insights and expertise. In addition to being a Super User, Chris is also a User Group leader, Microsoft MVP, and a featured speaker at the Microsoft Power Platform Conference. His contributions to the new SUIT program, along with his joyous personality and willingness to jump in and help so many members has made Chris a fixture in the Power Platform Community.   When Chris isn't authoring solutions or organizing events, he's actively leading Piasecki Consulting, specializing in solution architecture, integration, DevOps, and more--helping clients discover how to strategize and implement Microsoft's technology platforms. We are grateful for Chris' insightful help in the Community and look forward to even more amazing milestones as he continues to assist so many with his great tips, solutions--always with a smile and a great sense of humor.You can find Chris in the Community and on LinkedIn. Thanks for being such a SUPER user, Chris! 💪 🌠  

Find Out What Makes Super Users So Super

We know many of you visit the Power Platform Communities to ask questions and receive answers. But do you know that many of our best answers and solutions come from Community members who are super active, helping anyone who needs a little help getting unstuck with Business Applications products? We call these dedicated Community members Super Users because they are the real heroes in the Community, willing to jump in whenever they can to help! Maybe you've encountered them yourself and they've solved some of your biggest questions. Have you ever wondered, "Why?"We interviewed several of our Super Users to understand what drives them to help in the Community--and discover the difference it has made in their lives as well! Take a look in our gallery today: What Motivates a Super User? - Power Platform Community (microsoft.com)

March User Group Update: New Groups and Upcoming Events!

  Welcome to this month’s celebration of our Community User Groups and exciting User Group events. We’re thrilled to introduce some brand-new user groups that have recently joined our vibrant community. Plus, we’ve got a lineup of engaging events you won’t want to miss. Let’s jump right in: New User Groups   Sacramento Power Platform GroupANZ Power Platform COE User GroupPower Platform MongoliaPower Platform User Group OmanPower Platform User Group Delta StateMid Michigan Power Platform Upcoming Events  DUG4MFG - Quarterly Meetup - Microsoft Demand PlanningDate: 19 Mar 2024 | 10:30 AM to 12:30 PM Central America Standard TimeDescription: Dive into the world of manufacturing with a focus on Demand Planning. Learn from industry experts and share your insights. Dynamics User Group HoustonDate: 07 Mar 2024 | 11:00 AM to 01:00 PM Central America Standard TimeDescription: Houston, get ready for an immersive session on Dynamics 365 and the Power Platform. Connect with fellow professionals and expand your knowledge. Reading Dynamics 365 & Power Platform User Group (Q1)Date: 05 Mar 2024 | 06:00 PM to 09:00 PM GMT Standard TimeDescription: Join our virtual meetup for insightful discussions, demos, and community updates. Let’s kick off Q1 with a bang! Leaders, Create Your Events!  Leaders of existing User Groups, don’t forget to create your events within the Community platform. By doing so, you’ll enable us to share them in future posts and newsletters. Let’s spread the word and make these gatherings even more impactful! Stay tuned for more updates, inspiring stories, and collaborative opportunities from and for our Community User Groups.   P.S. Have an event or success story to share? Reach out to us – we’d love to feature you!

Users online (6,169)