web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / formula to check if to...
Power Automate
Unanswered

formula to check if today is Monday of the last week of the month

(0) ShareShare
ReportReport
Posted on by 247

hello all,

 

i was wondering is there a formula to check if today is :

 

Monday of the last week of the current month.

 

thank you in advance.

Categories:
I have the same question (0)
  • Verified answer
    Mira Ghaly Profile Picture
    11,413 Moderator on at

    @kouliscon 

    It is a little bit of Length Solution but will work , please find below steps:

    Mira_Ghaly_0-1626733380782.png

    Expression for No. 1: This get the first day of the last week of the current  month

    int(split(addDays(startOfMonth(body('NextMonth')),-7,'MM-dd-yyyy'),'-')[1])

      

    Expression for No. 2: This get the last day of the last week of the current  month

     

    int(split(addDays(startOfMonth(body('NextMonth')),-1,'MM-dd-yyyy'),'-')[1])

     

    Mira_Ghaly_1-1626733669806.png

    Expression for 3: This get the day of week

    1= Monday

    2=Tuesday 

    3= Wednesday ..

    Also please note here that you need to convert to your time zone

    https://docs.microsoft.com/en-us/previous-versions/windows/embedded/gg154758(v=winembedded.80)?redirectedfrom=MSDN

     

    dayOfWeek(convertFromUtc(utcNow(),'AUS Eastern Standard Time'))

     

    Expression 4: Day of Month

    dayOfMonth(convertFromUtc(utcNow(),'AUS Eastern Standard Time'))

     

    Also make sure in the first condition use 1 instead of 2

     

    Hope this works for you!

     

  • eliotcole Profile Picture
    4,363 Moderator on at

    Hi, @kouliscon 

     

    I think @Mira_Ghaly 's solution is probably better than mine, but I wanted to put all the logic out using pure actions (ish).

     

    Once you have this down, sliding much of it into expressions and functions will slim it down considerably, but this plots out the logic easily.

     

    I won't explain all of the actions here, because they're all pretty standard, the only tricky one is DO UNTIL which can sometimes be a little funny. If you can't get into the value side of the DO UNTIL, click "Edit in advanced mode" then click back to basic and it will open it up.

     

    However if anything looks odd, please say. ... ... Especially if I'm wrong. 😅

     

    Explanation

    1. Count up the days until it is next Month.
    2. Then count back the days until you reach a Monday.

     

    Full Flow

    Full FlowFull Flow

     

    Broken Down

    VariablesVariables

     

    Do Until Next MonthDo Until Next Month

     

    Do Until Is Last MondayDo Until Is Last Monday

     

    Define MondayDefine Monday

     

    Some of the Simple Expressions for Copy/Paste

    None of the expressions used here will be alien to a flow user after a few uses, I don't think.

     

    timeVAR

    This might sound silly to explain, but it's needed because it needs to continually be used and reset. Additionally it gives an easy reference for any expressions

     

    nxtMthVAR Expression

     

     

     

    int(formatDateTime(body('Add_a_month'), 'MM'))

     

     

     

    Firstly this formats the date and time of the "Add a month" action before into to numbers (eg: 07).

    Secondly this ensures that when it presents that '07' it is definitely presented as an integer type of number.

     

    monthVAR Expression

     

     

     

    int(formatDateTime(body('Add_a_day'), 'MM'))

     

     

     

    This is nearly the same expression as the nxtMthVAR, so it's basically picking out the numeric representation of whatever month the day addition has brought the flow into.

     

    Condition to check if it's next month

    This just looks to see if the number that you just generated in monthVAR is the same as the one that you worked out in nxtMthVAR at the very start.

     

    If the numbers match, the nxtMthMatchVAR is set to 'true', and the DO UNTIL will not iterate again.

     

    dayVAR Expression

     

     

     

     

    formatDateTime(variables('timeVAR'), 'dddd')

     

     

     

     

    This simply takes the time from timeVAR and displays the day as a word, in full (eg: Monday). 

     

    Condition to check if it's Monday

    This now checks to see if the day that you just generated in dayVAR is 'Monday'.

     

    If it is, then the isMonVAR is set to 'true', and the DO UNTIL will not iterate again.

     

    lastMondayOfThisMonthVAR

    This can now simply be set to the timeVAR which has now been wound forward, then back, until it is the right day!

  • kouliscon Profile Picture
    247 on at

    @Mira_Ghaly hello, and thank you for the detailed reply.

    i was trying to construct the flow based on what you send me but i am having issue with the first step as i dont know where or how to make it. Can you pls advice.

     

    Capture.PNG

     

    thank you

  • kouliscon Profile Picture
    247 on at

    never mind @Mira_Ghaly  i found it is called "Add to time".. let me see with the rest of the flow which looks great till now...

  • eliotcole Profile Picture
    4,363 Moderator on at

    That was from me, @kouliscon , but it's cool, yeah, sorry about that ... I could've renamed those better. 😅

     

    If you just follow the basic premise ... count up to the next month, count back to the last Monday, you'll make it ok. 🙂

     

    Everything else will fall in to place after that.

     

    Once you have those basics, you'll quickly condense a lot of these steps into expressions like in Mira's answer.

     

  • Mira Ghaly Profile Picture
    11,413 Moderator on at

    @kouliscon 

    Let  me know if this has worked for you or you are still facing some challenges!

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard