PowerAutomate Flow - Trigger Recurrence on the First Working Day of the Month

We may have scenarios where we would like the recurring flow to only run on the first working day of the month. For example, if the first day of the month falls over the weekend, either a Saturday or a Sunday, the flow should not trigger and wait until Monday.

I have a client who does monthly invoicing, and the invoice goes out on the first day of each month. They requested that we build a smart process in the background that can handle the two scenarios below.

Scenario 1:

If the first day of the Month falls on a Saturday, the monthly invoicing should run on Monday, the third Day of the month, as it becomes the first working day of the new month.

Scenario 2:

If the first day of the month falls on a Sunday, the monthly invoicing should run on Monday, i.e., the second Day of the Monday becomes the first working day of the new month.

Let us first understand how Power Automate understands the day of the week. Below is a table:

A. EVALUATION OF DAYS:

  1. Checking that the day part from today’s date is 1.

equals(int(utcNow('dd')),1)

2. We will now write an expression to evaluate if the day of the week is not Saturday.

not(equals(dayOfWeek(utcNow()),6))

3. We will now write an expression to evaluate if the day of the week is not Sunday.

not(equals(dayOfWeek(utcNow()),0))

Now let’s combine all the above three expressions as a single expression with an “and”.

and(equals(int(utcNow('dd')),1),not(equals(dayOfWeek(utcNow()),6)),not(equals(dayOfWeek(utcNow()),0)))

B. EVALUATE IF 1st WAS SUNDAY:

If 1st Day of the month falls on Sunday, the flow should trigger on Monday the 2nd.

  1. Checking that the day part from today’s date is 2.

    equals(int(utcNow('dd')),2)

2. We will now write an expression to evaluate if the day of the week is Monday.

equals(dayOfWeek(utcNow()),1)

Now let’s combine both the above two expressions into a single expression with an “and”.

and(equals(int(utcNow('dd')),2),equals(dayOfWeek(utcNow()),1))

C. EVALUATE IF 1st WAS SATURDAY:

If 1st Day of the month falls on Saturday, the flow should trigger on Monday the 3rd.

  1. Checking that the day part from today’s date is 2.

    equals(int(utcNow('dd')),3)

2. We will now write an expression to evaluate if the day of the week is Monday.

equals(dayOfWeek(utcNow()),1)

Now let’s combine both the above two expressions into a single expression with an “and”:

and(equals(int(utcNow('dd')),3),equals(dayOfWeek(utcNow()),1))

We are now done writing our required expressions. This is what we covered by writing and combining the above expressions.

  1. If it’s the 1st day, not Saturday or Sunday, run the flow.

  2. If it’s the 2nd day and it’s Monday, run the flow as the 1st day was Sunday.

  3. If it’s the 2nd day and it’s Monday, run the flow as the 1st day was Saturday.

Now, the final step is to combine all the above three expressions (in bold) as one gigantic expression, which will be added as a trigger condition. This final expression will be combined with an “or”.

or(

and(equals(int(utcNow('dd')),1),not(equals(dayOfWeek(utcNow()),6)),not(equals(dayOfWeek(utcNow()),0))),

and(equals(int(utcNow('dd')),2),equals(dayOfWeek(utcNow()),1)),

and(equals(int(utcNow('dd')),3),equals(dayOfWeek(utcNow()),1))

)

Let me show you what to do in Power Automate and how to add this expression as a trigger condition.

Note the frequency is set to everyday once. Your can configure your own time zone according to your location.

Copy and paste the entire expression in the trigger condition box and don’t forget to add an “@” sign. Click Done.

If you wish to test this trigger condition, create a “Manual trigger flow” and put the above expression without the “@” sign in a “Compose” action. You will get a “true” and “false” value.

If false, it means today was not the first day of the month. You can also play around with the expression by changing the day of the week and setting it to today's date as per your calendar to get a true value in the Compose output.

I’ll leave some testing for you!

If you need assistance leveraging advanced functionality in PowerAutomate, please feel free to contact the Centauri team.

Previous
Previous

A simple solution to add google autocomplete to form in Dynamics 365 Portal (Power Pages)

Next
Next

Deployment Pipelines in Power Platform