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

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. Our team will be reviewing posts using the new "Copilot" label to ensure we highlight and amplify the most relevant and recent content, so you're assured of high-quality content every time you visit. If you share a post that gets featured in the curated gallery, you'll get a PM in the Community to let you know!The curated gallery is ready for you to experience now, so visit the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community. We can't wait to see what you "cook" up!    

Tuesday Tips: Getting Started in the Community

TUESDAY TIPS is back!   This weekly series of posts is our way of sharing 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! The original run of Tuesday Tips was a highlight of last year, and these all-new Tips will hopefully prove to be just as informative as helpful. We will cover some basics about the Community, a few "insider tips" to make your experience even better, and sharing best practices gleaned from our most active community members and Super Users. Make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!   THIS WEEK: I'm Brand New! What Do I Do? The number of new community members we have each week is pretty amazing, and we are so glad to welcome all of you to the Community! You may be wondering. "What do I do? Where do I get started? Will anyone be willing to help me? What I have a question? Help!"   Let's start with this: Welcome to the low-code revolution, and more importantly, welcome to the Power Platform Community! This is a great place to start. Whether you're busy with Power Apps, getting familiar with Power Automate, engaging Copilot Studio, or building in Power Pages, there are a few key places you should check out as you begin your journey: FORUMS: The forums are THE place to ask questions, look at questions asked by other Community members—and see answers and solutions from our Super Users and other helpful people in the Community. Power Apps ForumsPower Automate ForumsCopilot Studio ForumsPower Pages Forums   NEWS & ANNOUNCEMENTS: Our News & Announcements section highlights the newest and greatest updates in the Community, news from the product team, and so much more. It’s updated a few times each week and will also help you find ways to connect with what’s going on in the ever-growing world of Power Platform. Power Apps News & AnnouncementsPower Automate News & AnnouncementsCopilot Studio News & AnnouncementsPower Pages News & Announcements   GALLERIES: The Galleries section of the Community features tons of tips and tricks, features and benefits, and more—through videos created by our Super Users, product teams, and other helpful members of the Community. Power Apps GalleriesPower Automate Galleries Copilot Studio GalleriesPower Pages Galleries BLOGS: The community blogs section is full of handy step-by-step tips from members of the Community—and some of them include detailed answers to some of the questions most frequently asked questions, as well as how they solved a problem they faced. Power Apps Community BlogPower Automate Community BlogCopilot Studio Community BlogPower Pages Community Blog POWER UP PROGRAM: If you’d like to really take a huge step forward in your journey, we recommend checking out the Power Up Program, a Microsoft-sponsored initiative that trains new Power Platform users and has been a huge success since it launched a little over a year ago. There’s a waiting list, so definitely apply soon if you’re interested! Find out more here: Microsoft Power Up Program for career switchers.   There's so much more you'll discover in your Power Platform experience, and this Community is here for YOU! We are glad you've discovered us and can't wait to see where you grow! If you're new to the Community and just getting started, make sure to give this post a kudo and introduce yourself so we can welcome you!

Super User of the Month | Drew Poggemann

As part of a new monthly feature in the Community, we are excited to share that Drew Poggemann is our featured Super User for the month of February 2024. If you've been in the Community for a while, we're sure Drew's name is familiar to you, as he is one of our most active contributors--he's been a Super User for five consecutive seasons!   Since authoring his first reply 5 years ago to his 514th solution authored, Drew has helped countless Community members with his insights and expertise. In addition to being a Super User, Drew is also a User Group leader and a Microsoft MVP. His contributions to our Super User sessions and to the new SUIT program are always welcome--as well as his sense of humor and fun-loving way of sharing what he knows with others.   When Drew is not solving problems and authoring solutions, he's busy overseeing the Solution Architecture team at HBS, specializing in application architecture and business solution strategy--something he's been doing for over 30 years. We are grateful for Drew and the amazing way he has used his talent and skills to help so many others in the Community. If you are part of the SUIT program, you got to hear some great tips from Drew at the first SUIT session--and we know he still has much more to share!You can find him in the Community and on LinkedIn. Thank you for all you do, Drew!

Celebrating a New Season of Super Users with Charles Lamanna, CVP Microsoft Business Applications

February 8 was the kickoff to the 2024 Season One Super User program for Power Platform Communities, and we are thrilled to welcome back so many returning Super Users--as well as so many brand new Super Users who started their journey last fall. Our Community Super Users are the true heroes, answering questions, providing solutions, filtering spam, and so much more. The impact they make on the Communities each day is significant, and we wanted to do something special to welcome them at our first kickoff meeting of the year.   Charles Lamanna, Microsoft CVP of Business Applications, has stressed frequently how valuable our Community is to the growth and potential of Power Platform, and we are honored to share this message from him to our 2024 Season One Super Users--as well as anyone who might be interested in joining this elite group of Community members.     If you want to know more about Super Users, check out these posts for more information today:    Power Apps: What is A Super User? - Power Platform CommunityPower Automate: What is A Super User? - Power Platform Community Copilot Studio: What is A Super User? - Power Platform Community Power Pages: What is A Super User? - Power Platform Community

Super Users 2024 Season One is Here!

   We are excited to announce the first season of our 2024 Super Users is here! Our kickoff to the new year welcomes many returning Super Users and several new faces, and it's always exciting to see the impact these incredible individuals will have on the Community in 2024! We are so grateful for the daily difference they make in the Community already and know they will keep staying engaged and excited for all that will happen this year.   How to Spot a Super User in the Community:Have you ever written a post or asked for help in the Community and had it answered by a user with the Super User icon next to their name? It means you have found the actual, real-life superheroes of the Power Platform Community! Super Users are our heroes because of the way they consistently make a difference in the Community. Our amazing Super Users help keep the Community a safe place by flagging spam and letting the Community Managers know about issues. They also make the Community a great place to find answers, because they are often the first to offer solutions and get clarity on questions. Finally, Super Users share valuable insights on ways to keep the Community growing, engaging, and looking ahead!We are honored to reveal the new badges for this season of Super Users! Congratulations to all the new and returning Super Users!     To better answer the question "What is a Super User?" please check out this article: Power Apps: What is A Super User? - Power Platform CommunityPower Automate: What is A Super User? - Power Platform Community Copilot Studio: What is A Super User? - Power Platform Community Power Pages: What is A Super User? - Power Platform Community

Microsoft Power Platform | 2024 Release Wave 1 Plan

Check out the latest Microsoft Power Platform release plans for 2024!   We have a whole host of exciting new features to help you be more productive, enhance delegation, run automated testing, build responsive pages, and so much more.    Click the links below to see not only our forthcoming releases, but to also try out some of the new features that have recently been released to market across:     Power Apps  Power Automate  Copilot Studio   We can’t wait to share with you all the upcoming releases that will help take your Power Platform experience to the next level!    Check out the entire Release Wave: Power Platform Complete Release Planner 

Users online (2,756)