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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Filter Query for certa...
Power Automate
Answered

Filter Query for certain months

(0) ShareShare
ReportReport
Posted on by 726

Im using the filter query in 'Get Items' from a sharepoint list to pull only for the current month, running the report at the end of the month and showing data from the last 31 days, Works perfectly. 

 

I have now been asked if i can get reports for the last 6 months, one for each month how can i edit my filter query to pull this data?

 

this is my current filter 

Created ge '@{formatDateTime(startOfMonth(utcNow()),'yyyy-MM-dd')}' and Created lt '@{formatDateTime(utcNow(),'yyyy-MM-dd')}'

amyharkus86_0-1684921075906.png

 

Categories:
  • v-wenjuan-msft Profile Picture
    Microsoft Employee on at

    Hi @amyharkus86 ,

     

    If you would like to retrieve data for each month and generate 6 reports in a single flow, advice is to get data of last 6 months first in "Get items". Then you can use 6 "Filter arrays" to divide them into 6 month.

     

     

    Created ge '@{formatDateTime(subtractfromtime(startOfMonth(utcNow()),6,'Month'),'yyyy-MM-dd')}' and Created lt '@{formatDateTime(utcNow(),'yyyy-MM-dd')}'

     

     

    In filter array, refer to below function:

    vwenjuanmsft_0-1684922868734.png

     

    And(greaterOrEquals(item()?['Created'], formatDateTime(subtractfromtime(startOfMonth(utcNow()), 6, 'Month'), 'yyyy-MM-dd')),less(item()?['Created'], formatDateTime(adddays(subtractfromtime(startOfMonth(utcNow()), 5, 'Month'), -1), 'yyyy-MM-dd')))

    It will retrieve data from 2022-11-01~2022-11-30.

     

    Community Support Team _ Wenjuan Zou

    If this post helps, then please consider Accept it as the solution to help the other members find it.

  • amyharkus86 Profile Picture
    726 on at

    @v-wenjuan-msft It might only be the one month, So i was working on the idea of just running it for say April and if that is whats she needs i can edit it to get each month. 

     

    What would be the best way to do that ?

  • v-wenjuan-msft Profile Picture
    Microsoft Employee on at

    Hi @amyharkus86 ,

     

    I made a complement to my answer.

    Sorry but I failed to get your new comment...Could you explain further on what do you need exactly...

     

    Community Support Team _ Wenjuan Zou

    If this post helps, then please consider Accept it as the solution to help the other members find it.

  • amyharkus86 Profile Picture
    726 on at

    @v-wenjuan-msft i'd like to filter the date for last month only, April.

  • Verified answer
    v-wenjuan-msft Profile Picture
    Microsoft Employee on at

    Hi @amyharkus86 ,

     

    Try this:

    Created ge '@{formatDateTime(subtractfromtime(startOfMonth(utcNow()), 1, 'Month'), 'yyyy-MM-dd'))}' and Created lt '@{formatDateTime(adddays(startOfMonth(utcNow(), -1), 'yyyy-MM-dd'))}'

     

    Community Support Team _ Wenjuan Zou

    If this post helps, then please consider Accept it as the solution to help the other members find it.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 307 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 289

#3
Henil Profile Picture

Henil 127

Last 30 days Overall leaderboard