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 / How to get previous mo...
Power Automate
Unanswered

How to get previous months data from a Sharepoint List?

(0) ShareShare
ReportReport
Posted on by 514

 

I am trying to get the previous months data in a Sharepoint List from a given date.

 

I tried 

 

DateinList ge startOfMonth(getPastTime(1,'MONTH'),'yyyy-MM-dd')

 

Running in Jan, I expected to see December records only, but it brought Jan ones through also.

I just need it to always return the previous months data.

Any help appreciated.

Thank you

 

 

Categories:
  • Hardesh15 Profile Picture
    7,087 Super User 2024 Season 1 on at

    @sienna28  you are using 'ge' which means that greater than equal to. If condition finds data greater than equal to defined date then it will give you complete date from defined date. What is cut off date?

    Please 'Thumbs Up' the posts that helped you and 'Mark as Solution' if my post answered your question.

    @Hardesh

  • sienna28 Profile Picture
    514 on at

    Thanks for replying.

     

    I just need the data for the previous month to the one we are currently on.

    So now in Jan so need everything in Dec.

    Feb would need everything in Jan 

    etc

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @sienna28 ,

    Don't you need an and filter besides your existing filter?

    DateinList ge startOfMonth(getPastTime(1,'MONTH'),'yyyy-MM-dd') and DateinList lt startOfMonth(utcNow(),'yyyy-MM-dd')

     

    https://powerusers.microsoft.com/t5/Building-Flows/Flow-Query-Filter-Date-Range/td-p/192270

  • Hardesh15 Profile Picture
    7,087 Super User 2024 Season 1 on at

    @sienna28 See this expression gave you start of month of pre. month -

    1.Lets say i put this in compose
    startOfMonth(getPastTime(1,'MONTH'),'yyyy-MM-dd')
    As you know JAN-31 days, Feb 28/29 days, March-31, April-30 days etc..
    If your current month is Feb then you need to get end date for Jan month. For this you will
    add 30 days to get last date of JAN month.
    2. Use one more compose to get your previous month using adddays(utcnow(),-10,'MM'). I used 10 here if you are running your flow before 10 days you can change this accordingly.
    3.Use another compose and create condition for each month & add days-
    if(equals(outputs('GetMonth'),'01'),addDays(outputs('compose'),30,'yyyy-MM-dd'),if(equals(outputs('GetMonth'),'02'),addDays(outputs('compose'),27,'yyyy-MM-dd'),if(equals(outputs('GetMonth'),'03'),addDays(outputs('compose'),30,'yyyy-MM-dd'),if(equals(outputs('GetMonth'),'04'),addDays(outputs('compose'),29,'yyyy-MM-dd'),if(equals(outputs('GetMonth'),'05'),addDays(outputs('compose'),30,'yyyy-MM-dd'),if(equals(outputs('GetMonth'),'06'),addDays(outputs('compose'),29,'yyyy-MM-dd'),if(equals(outputs('GetMonth'),'07'),addDays(outputs('compose'),30,'yyyy-MM-dd'),if(equals(outputs('GetMonth'),'08'),addDays(outputs('compose'),30,'yyyy-MM-dd'),if(equals(outputs('GetMonth'),'09'),addDays(outputs('compose'),29,'yyyy-MM-dd'),if(equals(outputs('GetMonth'),'10'),addDays(outputs('compose'),30,'yyyy-MM-dd'),if(equals(outputs('GetMonth'),'11'),addDays(outputs('compose'),29,'yyyy-MM-dd'),if(equals(outputs('GetMonth'),'12'),addDays(outputs('compose'),30,'yyyy-MM-dd'),''))))))))))))
    4. Now step 3 gave you previous month end date.
    5. Use condition if your date is ge Step-1 and le step 3.
    In this way you can get previous month data.

    Note: i have not included condition for feb-29 days.

    Please 'Thumbs Up' the posts that helped you and 'Mark as Solution' if my post answered your question.

    @Hardesh

  • sienna28 Profile Picture
    514 on at

    Thank you both

     

    soysalf solution seems to work.

     

    Hoping it could work for any month it is run.

  • Hardesh15 Profile Picture
    7,087 Super User 2024 Season 1 on at

    Thanks @Anonymous  for such crispy solution.

  • sienna28 Profile Picture
    514 on at

    Thanks also Hardesh for looking at this for me.

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