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 / Filter tasks on Planne...
Power Automate
Answered

Filter tasks on Planner for all tasks created in the previous month

(0) ShareShare
ReportReport
Posted on by 195

Hi,

 

I'm currently building a flow and the part I am now stuck on is filtering tasks from a Planner that have a completed date for the previous month.

 

I am comparing planner tasks and SharePoint items from the past month. 

 

I have a  filter query on the SharePoint list but I am having trouble with the filter array on tasks which comes back with the error :

roxy1_0-1666837421834.png

 

roxy1_1-1666837463812.png

The expression in the filter array I am using is:

@And(greater(item()?['createdDateTime'], startOfMonth(getPastTime(1, 'MONTH')),less(item()?['createdDateTime'], startOfMonth(utcNow()))

 

I've so much wonderful help from this community - thank you to everyone who sees this 🙂

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

    it looks like you're missing a couple of closing ) in your expression. One for greater and one for less.

     

    I would have actually done this slight differently to you (always lots of ways to solve the same thing). I would get the past date (1 month ago) and format it as yyyy-MM as we are only interested in the month within a particular year.

     

    Then I would format each of the task dates with yyyy-MM and see if they're equal to the date one month ago.

     

    See below:

    grantjenkins_0-1666847351979.png

     

    List tasks just gets all the tasks from a particular planner.

     

    Get past time One Month ago gets the current date minus one month

    grantjenkins_1-1666847529162.png

     

    Compose Last Month formats the Past time with yyyy-MM

     

    formatDateTime(body('Get_past_time_One_Month_ago'), 'yyyy-MM')

     

    grantjenkins_2-1666847587388.png

     

    Filter array formats each item (createdDateTime) with yyyy-MM and checks to see if they are equal to Compose Last Month.

     

    formatDateTime(item()?['createdDateTime'], 'yyyy-MM')

     

    grantjenkins_3-1666847655169.png

     

  • roxy1 Profile Picture
    195 on at

    Wonderful! Thank you for your help again @grantjenkins - happy to learn new ways to solve these issues too. I have not used "get past time" before so thank you!

  • roxy1 Profile Picture
    195 on at

    Can I pick your brain @grantjenkins - would there be a reason when a filter query on a SharePoint list is not returning items from the 1st of the month?! I am checking the outputs and it is missing two items dated 1/9/22.

     

    The list column setting has a date only value no time

     

    roxy1_0-1666854416372.png

    the expressions used are Date ge '@{startOfMonth(getPastTime(1,'MONTH'))}' and Date lt '@{startOfMonth(utcNow())}'

     

  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    It's likely due to the UTC time zone and your actual time zone (might be out enough so dates close to the start/end of the month may get missed). I would probably convert the date to your time zone to ensure you are getting the correct results all the time.

  • roxy1 Profile Picture
    195 on at

    Thanks @grantjenkins that is most very likely the reason. What a pain!

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 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard