Showing results for 
Search instead for 
Did you mean: 
Regular Visitor

I'm trying to send an email by comparing a future date to several date fields in an excel table

Hello All!


First, I'd like to give you some background on my task at hand.  As the DOT Compliance Administrator, I have an excel spreadsheet which contains columns for all of our drivers, their credential expiration dates, along with several columns that contain formulas to compare those expiration dates to today's date and auto-fill with "yes" or "no" as to whether they're qualified to drive a vehicle, and if they also have an CDL, that they are also qualified to drive another specific kind of vehicle.  Each date in the column is also conditionally formatted to display a certain color based on how far into the future the date occurs compared to today.  So, there is a "legend" at the top of the page describing what each color means.  The color-coding would be meaningless without it.  Because of this, my column headers do not start in cell A1, more like A9.  As such, I haven't been able to work out a way to use this spreadsheet to extract the data I want to use to send an email reminder to the driver, his or her supervisor, the safety manager, and myself, when their credential expires 30 days and 7 days in the future, for example, from today.




Thus, it seems that my first task is to replicate this file to a new one containing an excel table that power automate would be able to "read," which would only contain the drivers' names, the expiration dates, and the email addresses, without all of the formatting and formulas.  The caveat being that any updates/additions/subtractions to the original file (i.e. adding a new driver, marking one "Inactive," or changing a date to a new date in the future) would automatically replicate over to the new file without having to open it to "refresh all" or run a macro.  The original file contains a switch, or filter, to make only active drivers visible, but the information for the inactive drivers is still there.


Then, I feel my next task would be to use power automate on the new file to compare those dates, so that an email reminder is automatically generated daily (scheduled flow) and sent to each recipient based on the same criteria as the color-coding of the legend in the original file.  I would also like to send a different email with more urgency if their credential dates have already expired (red) or there is no date at all (purple).  Obviously, I don't want the flow to evaluate the dates of drivers that are inactive.


If I'm over-simplifying this, and have left out any critical step(s), I'd also appreciate any feedback as to what those steps might be.  My goal is to automate this process as much as possible so as not to need to go physically check the file everyday for credentials that are expiring soon.  

Super User
Super User

I don't think you're simplifying, you've got it - the biggest issue will be converting dates, but, we'll get that.


For your main flow...


Step 1) Turn this thing into a table. I don't think you need to create a whole new sheet or anything. Just set it up as a table - highlight it, convert to table. It'll keep your formulas. Formulas are no biggie, Power Automate can handle that - it'll show you the value you need.

Step 2) Create a scheduled daily flow that runs a query on your table using the "List rows present in table", and the Filter Query. You would likely have one of these for each of your required frequencies - ie, today, next week, one month.

➡️For "Expiry is Today!" you could have something like  "ExpiryDate eq @{div(sub(ticks(formatDateTime(utcNow(),'M/dd/yyyy')),ticks('1899-12-30')),864000000000)}" -- where ExpiryDate is the name of your column. This will bring back all entries that have an ExpiryDate of UTC today. 


➡️For "Expiry is in a Week!" you could have something like  "ExpiryDate eq @{div(sub(ticks(formatDateTime(addDays(utcNow(),7),'M/dd/yyyy')),ticks('1899-12-30')),864000000000)}" -- This will bring back all entries that have an ExpiryDate of UTC today PLUS 7 days.

Step 3) If you return values, send emails. If you don't, move onto the next frequency. Your flow might look something like this:




And that's it.   EXCEPT!!!!!!!!!!!!


Your purple stuff. Honestly, the fact that they're empty, to me, is a one time email, or, you need a word in there. Ie, "Mailed 2022" or "No Expiration" or something to tell us why it's purple. That way, you can create a flow that says "find all empty expiration dates and tell their owner that they need to send me the expiration date." Then, populate those empty squares with "Mailed 2022" or "Mailed One Time" or SOMETHING so that you don't end up spamming them.  

I'd want to hear more about how you want to handle the purple stuff.






Did this answer your question? Please mark it as the solution.
Did it contribute positively towards finding the final solution? Please give it a thumbs up.

I answer questions on the forum for 2-3 hours every Thursday!

Thank you @Rhiassuring for your valuable information.  Would it be better to have the evaluation of the dates in series, or a combination of parallel and series, rather than running them parallel, since in your example, I would need to create a version that looks at today, 7 days, and 30 days for each of the four columns (driver license, MVR, Med Card, and Annual Review)?  I would think that I might exceed the flow's "transaction" limit if I tried to run all of them in parallel branches, because I would end up with 12 branches all on the same level.


As for the empty (purple) fields, all four of the columns are validated to only accept a date in the format shown (yyyy-mm-dd), as other users were trying to make long notes in there, and that was causing all kinds of errors in the other columns to the right, that aren't shown in my screenshot, to evaluate a driver's eligibility to drive a company vehicle.  Those columns check to see if all the dates are greater than today's date and returns a "Yes" or "No" in that column based on all four columns satisfying that criteria. 

Super User
Super User

Ah, I see what you're saying. In that case, I'd probably just get all items and then filter the output based on your need. 

So my super simplified example is this:


If you get all items, then filter query per need, you can take that info and put it into an Array - so that way, you can use it on one email at the end. In this example I'm only showing 7 days Med Card. All the stuff between "initialize variable" and "apply to each - send all emails" would be done for each. 

The filter array is the same as the filter query, but, I wrapped it in a "string()" so it can compare. Then I use a Parse JSON on the output of that, so I can grab the values, and put them into building the "arrCards". Inside of the "append to array variable", I have this:

"CardType": "Medical",
"Email": "@{items('Apply_to_each_-_for_each_7_day_med_card')['Email]}",
"Days": "7",
"Subject": "URGENT: Your Medical card will expire in 7 days!"

Basically just taking what I need to compose the emails, and putting it into a single array. 


Basically just taking what I need




Did this answer your question? Please mark it as the solution.
Did it contribute positively towards finding the final solution? Please give it a thumbs up.

I answer questions on the forum for 2-3 hours every Thursday!

@Rhiassuring Thank you, but I can't get your examples to work.  I think it's because I forgot to mention, in my original post, that the file I'm working with is stored in a Sharepoint library.  So, getting the rows from the table has been impossible, as the only option for me to use to get the rows is Excel Online.  I don't have the ability to use that with the security protocols currently in place within our organization.  I tried using getting file content under the Sharepoint actions, but there isn't an option for getting the rows, at least not in the version of PA my company allows me to use.

Super User
Super User

Yes, Excel Online is the only option.

Your Excel action will just look like this instead:



Your SharePoint site should appear in the dropdown. You navigate to it the same way.



Did this answer your question? Please mark it as the solution.
Did it contribute positively towards finding the final solution? Please give it a thumbs up.

I answer questions on the forum for 2-3 hours every Thursday!

Hi, @Rhiassuring!  I finally got the access to Excel Online resolved, and following your script for the 'TODAY' filter query, I ran my first test flow.  Unfortunately, it failed with a description I'm not quite sure how to decipher:


{"statusCode":400,"headers":{"Pragma":"no-cache","x-ms-request-id":"0b0e6861-00d6-40bf-8b98-ddf2854af020","Strict-Transport-Security":"max-age=31536000; includeSubDomains","X-Content-Type-Options":"nosniff","X-Frame-Options":"DENY","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"false","x-ms-apihub-obo":"true","Cache-Control":"no-store, no-cache","Date":"Tue, 23 Aug 2022 22:41:29 GMT","Content-Length":"480","Content-Type":"application/json","Expires":"-1"},"body":{"status":400,"message":"Syntax error at position 14 in 'DRIVER LICENSE eq 44796'.\r\n     inner exception: Syntax error at position 14 in 'DRIVER LICENSE eq 44796'.\r\nclientRequestId: 0b0e6861-00d6-40bf-8b98-ddf2854af020","error":{"message":"Syntax error at position 14 in 'DRIVER LICENSE eq 44796'.\r\n     inner exception: Syntax error at position 14 in 'DRIVER LICENSE eq 44796'."},"source":""}}


Here's my flow step:







Helpful resources


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

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 (4,910)