cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Krickner
Helper II
Helper II

Using ODATA Filter Query on Get Items to Compare SharePoint List Date & Excel Date

Hello, first, thank you for looking into this issue, I appreciate you and your time.

I have an automated flow that triggers when a new excel file has been created in one of my SharePoint Libraries.  The flow creates a table in the excel file and then does an 'Apply_to_each' Get Items from my SharePoint List (Named: Shipping List).  I have an ODATA Filter Query that needs to compare Job Number and Due Date fields between the excel file and SharePoint List.  Those fields are used because they'll never be replicated.

 

This is to determine if Power Automate must create a new SharePoint list item or update an existing one.  I keep getting the following error:

Krickner_2-1679503531954.png

"Title" is my SharePoint column ID for "Job Number", the "200164-25" is just one example of a job number.  "Field_4"is Due Date.

 

 

I believe the issue is due to the date format, as it's probably coming in from the "List rows present in a table" in one format, while Get Items from the SharePoint list is in another format.  I don't know how to resolve this issue. (See Flow Below)


Krickner_1-1679503750379.png

 

 

 

Krickner_1-1679503448912.png

 

______________________________________________________________

 

Here is the formula I'm using to attempt to fix the issue, however, even without manipulating the date, it did not work.  Still, every ODATA filter query fails to find a match.

 

Krickner_0-1679504882991.png

----------------------------------------------------------------------------------------------------------------------------------

 

Krickner_0-1679504300716.png

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Krickner
Helper II
Helper II

@Sundeep_Malik, I finally got it to work, and I really appreciate your help on this one.  Oddly enough, I returned to the original flow and made one adjustment.  When formatting the date on the ODATA filter, I had to use hyphens "-" instead of forward slashes "/", and I also had to use the format "MM-dd-yyyy."  I'm posting the entire flow so that others can benefit should they need a flow like this. 

  1. The flow waits for an excel sheet to upload to a specific SharePoint library, which triggers the flow.
  2. Creates an excel table within the excel sheet with existing data.
  3. Gets items from a SharePoint list and compares the Excel table to SharePoint items.
  4. If an item already exists in the SharePoint list, the flow updates the SharePoint list item.
  5. The flow creates a new SharePoint list item if the item does not exist.

This flow also uses a document upload status field to let users know when the flow has been completed.  You must delete this logic if you do not want to create a custom document upload status field in your SharePoint library.

Krickner_1-1679918583915.png

Krickner_3-1679919084198.png

Krickner_4-1679919270391.png

Krickner_6-1679919600852.png

Krickner_7-1679920281628.png

Krickner_8-1679920646108.png

Krickner_10-1679920951875.png

 

 

 

 

 

 

 

View solution in original post

19 REPLIES 19
Sundeep_Malik
Multi Super User
Multi Super User

Hey @Krickner 

 

Do the condition like this:

 

(Title eq 'JobNumber') and (field_4 eq 'formatdatetimeexpression')

 

 

I'm going to try this now @Sundeep_Malik .  I'll update you in a few.  thank you : )

@Sundeep_Malik the same error occurred.  My instinct is telling me it has to do with date formatting, but I don't know how to see which date format the SharePoint list is using.  I set the "list rows present in a table (excel)" format to MM/dd/yyyy.  

Krickner
Helper II
Helper II

I also tried changing the "formatdate" to be "MM/dd/yyyy" which excludes the time.  My SharePoint List column is not set up to display time (see below).  I figured it would be a long shot as I'm pretty sure it keeps that data on the backend and uses it when importing into Power Automate.  Never-the-less, it did not work.

Krickner_0-1679506184382.png

 

Krickner
Helper II
Helper II

I have been able to verify that the issue lies in the "field_4 (DueDate)" portion of the ODATA Filter Query, as I removed that portion and just left my job number and the flow ran successfully.  

When the flow ran successfully I was able to see the data format GET ITEMs was pulling from my Due Date field out of my SharePoint List, and it was "yyyy/MM/dd"  So, I adjusted the ODATA filter Query to match that format "

formatDateTime(items('Apply_to_each')?['DueDate'], 'yyyy/MM/ddT00:00:00.000Z')and it still didn't work.  😥 😪 
Sundeep_Malik
Multi Super User
Multi Super User

@Krickner 

No, it's nothing to do with the time format currently. I think the problem could be because of apply to each. I will try to replicate it on my end tomorrow. Hopefully someone else till then would get back to you.

Sundeep_Malik
Multi Super User
Multi Super User

@Krickner 

 

I want you to try some things, can you filter with 1 condition at a time, lets see which one is giving error.

 

Try one more thing. Run the flow without any filter query. In the next step add a compose and in that pass the value expression you are getting from get items. Could be possible the field stored in Sharepoint for field_4 and Title could be different name. Though as you have already entered field_4 I am suspecting you have already done that.

 

Lastly, if one condition works, use a filter query action and filter the array you are getting from get items on the other condition. I found some posts where people have done that.

 

I hope this helps 🙂

Sundeep_Malik
Multi Super User
Multi Super User

@Krickner 

 

and also instead of this : formatDateTime(items('Apply_to_each')?['DueDate'], 'yyyy/MM/ddT00:00:00.000Z')

use this:

formatDateTime(items('Apply_to_each')?['DueDate'], 'yyyy/MM/dd')

I tried filtering by just the Job Number (Title), and the flow worked.  I didn't try just filtering field_4 (Date), but I'll do that now.  Yeah, I verified the field names in Share Point.  Okay, so I should leave the ODATA filter in Get Items for SharePoint field (Title), but before the condition, I should insert a Filter Query action?

Sundeep_Malik
Multi Super User
Multi Super User

@Krickner 

 

So, just keep Title in get items filter query.

 

After that get items, use filter array action and filter the array you are getting from get items on the field_4. 

Krickner
Helper II
Helper II

@Sundeep_Malik the flow succeeded, but no data is getting created or edited.  I did a test by changing some of the data expecting the condition to see it as a new line item, and create a list item.  The flow runs, but it's almost as if it's skipping my condition (see below)

Krickner_1-1679681563890.png

 

 

Krickner
Helper II
Helper II

Here is the result after the changes.

 

Krickner_2-1679681651036.png

 

Sundeep_Malik
Multi Super User
Multi Super User

@Krickner 

Oh! See your filter array result is null, that's why it is getting skipped in condition. 

 

Now in filter query match the date formats by writing the formatDateTime function on both sides:

 

formatDateTime(duedateexpressionfromgetitems,'MM-dd-yyyy')

Equals 

formatDateTime(duedateexpressionfromexcel,'MM-dd-yyyy')

 

 

Or a format of your own choice.

 

I hope this helps 🙂

Krickner
Helper II
Helper II

@Sundeep_Malik did I write these expressions wrong?  In both sets of data I have matching dates, but the Filter Array is coming back Null.  

 

Krickner_0-1679686251646.png

 

--------------------------------------------------------------------------------------------------------

 

Krickner_1-1679686388888.png

 

Sundeep_Malik
Multi Super User
Multi Super User

@Krickner 

I am really confused here. Everything looks correct to me but even the input is coming as null. That shouldnt be happening. 😥

 

Input is the value you are getting from get items, that can never be null. I am sure you might have double checked that you are getting data from that get items. But I am really confused here.

Let me try it on a test data at my end.

Sundeep_Malik
Multi Super User
Multi Super User

@Krickner 

So, I tried formatDateTime function on both sides of filter array and it worked.

 

Some things to notice:

 

1) The input is empty so you might not be getting something from get items

2) Try this: on left side only add due date dynamic expression, no item() function and on right side use formatDateTime function and match it to similarly stored in SharePoint. Or vice versa, on left formatdatetime function and on right directly due date from Excel value

3) Try this: Instead of item()[field_4] use item()[Duedate], use single quotes too. Hehe. 

Krickner
Helper II
Helper II

@Sundeep_Malik 

It shows as pulling from Get Items, I tried to use the dynamic field on the left like you instructed and got the same result, null input on the Filter array.  I just don't understand why it's not showing any inputs.  The Filter array is in a Apply to each loop, is that causing an issue?

 

Krickner_0-1679689260455.png

 

Sundeep_Malik
Multi Super User
Multi Super User

@Krickner 

Oh! Correct. So for some of the iterations it might be null, check for other iterations is it working.

Krickner
Helper II
Helper II

@Sundeep_Malik, I finally got it to work, and I really appreciate your help on this one.  Oddly enough, I returned to the original flow and made one adjustment.  When formatting the date on the ODATA filter, I had to use hyphens "-" instead of forward slashes "/", and I also had to use the format "MM-dd-yyyy."  I'm posting the entire flow so that others can benefit should they need a flow like this. 

  1. The flow waits for an excel sheet to upload to a specific SharePoint library, which triggers the flow.
  2. Creates an excel table within the excel sheet with existing data.
  3. Gets items from a SharePoint list and compares the Excel table to SharePoint items.
  4. If an item already exists in the SharePoint list, the flow updates the SharePoint list item.
  5. The flow creates a new SharePoint list item if the item does not exist.

This flow also uses a document upload status field to let users know when the flow has been completed.  You must delete this logic if you do not want to create a custom document upload status field in your SharePoint library.

Krickner_1-1679918583915.png

Krickner_3-1679919084198.png

Krickner_4-1679919270391.png

Krickner_6-1679919600852.png

Krickner_7-1679920281628.png

Krickner_8-1679920646108.png

Krickner_10-1679920951875.png

 

 

 

 

 

 

 

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community 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  

Tuesday Tip | How to Report Spam in Our Community

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.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (2,617)