cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
franzerman
Frequent Visitor

Send an email with information from excel sheet, filtering by rows with dates in the same week

Hi!

I have an excel sheet with tasks and activities for every day of the week, and I would like to develop a flow that reads the excel sheet every morning and sends an email with the activities due to the current week.

 

My excel sheet has the following columns:

activityName | startDate | endDate

 

I want to send an email with the activities which end this week, but I'm having trouble getting a value for the week from utcNow() or the date in the endDate column.

 

Any advice is welcome!

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @franzerman,

 

I would say this would be possible by using a filter query on a List rows present in a table action:

https://docs.microsoft.com/en-us/connectors/excelonlinebusiness/#list-rows-present-in-a-table

 

In my example below I am using a Excel file with a table (Table1) stored on OneDrive which looks like this.

 

weeklyactivities.png

 

Within Power Automate I am using the List rows present in a table action which is using the following value for the filter query. I am using the Short date pattern (d) in my example, since I am using that same date pattern in my Excel file https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings.

startDate eq '@{utcNow('d')}'

startdateequals_filterquery.png

 

The end result of my example is that I will only retrieve Task 1, 4 and 7.

 

outputexcelfilterquery.png

 

Hopefully this is useful to get you started?



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


View solution in original post

5 REPLIES 5
Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @franzerman,

 

I would say this would be possible by using a filter query on a List rows present in a table action:

https://docs.microsoft.com/en-us/connectors/excelonlinebusiness/#list-rows-present-in-a-table

 

In my example below I am using a Excel file with a table (Table1) stored on OneDrive which looks like this.

 

weeklyactivities.png

 

Within Power Automate I am using the List rows present in a table action which is using the following value for the filter query. I am using the Short date pattern (d) in my example, since I am using that same date pattern in my Excel file https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings.

startDate eq '@{utcNow('d')}'

startdateequals_filterquery.png

 

The end result of my example is that I will only retrieve Task 1, 4 and 7.

 

outputexcelfilterquery.png

 

Hopefully this is useful to get you started?



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Expiscornovus
Most Valuable Professional
Most Valuable Professional

In addition to that startday approach above you can use the following steps to get all the tasks from this week based on the startdate of a task.

 

This is example is using the get first day of the week approach, described by Fausto Capellan, Jr

https://faustocapellan.com/2020/06/16/how-to-3-get-first-day-of-the-week-using-power-automate/

 

In my example below I am assuming that the first day starts on Monday btw.

 

1. Remove the filter query expression

2. Add an apply to each and use the results of the List rows present in table action (from my previous example)

3. Add a condition and use the following two condition rows in an AND group

 

 

formatDateTime(items('Apply_to_each')?['startDate'], 'MM-dd-yyyy')

 

 

 is greater than or equal to

 

 

formatDateTime(subtractFromTime(addDays(utcNow(), 1), dayOfWeek(utcNow()), 'Day'), 'MM-dd-yyyy')

 

 

AND

 

 

formatDateTime(items('Apply_to_each')?['startDate'], 'MM-dd-yyyy')

 

 

 is less than or equal to

 

 

formatDateTime(subtractFromTime(addDays(utcNow(), 7), dayOfWeek(utcNow()), 'Day'), 'MM-dd-yyyy')

 

 

 firstdayofweekfilter.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


franzerman
Frequent Visitor

Thank for the clear explanation! Will try this!

This solution kind of works, but the 'Apply to each' results in the flow sending an email for each activity that meets the conditions. Is there a way to join all those activities in a new table and send just 1 email?

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @franzerman,

 

You could use the following approach for that.

 

1. Add a initialize variable action in the beginning of your flow. I called it TaskOverview

taskoverviewvariable.png

2. In the apply to each loop you can add an append to variable action. 

appendtostring_taskoverview.png

 

3. Place an send email action outside of the loop and use the TaskOverview variable in the body of that single e-mail.

sendemail_taskoverview.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Helpful resources

Announcements

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  

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

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,897)