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
Super User
Super User

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?

View solution in original post

5 REPLIES 5
Expiscornovus
Super User
Super User

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?

Expiscornovus
Super User
Super User

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

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
Super User
Super User

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

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,078)