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 / Finding MAX value base...
Power Automate
Suggested Answer

Finding MAX value based on Dates in File Names

(0) ShareShare
ReportReport
Posted on by 128
I am trying to create a Power Automate Flow. In a SharePoint folder I have many excel files. Each of the excel files follow the below naming convention. yyyy_MM_dd-ABCD EFGH. My requirement is I need to find the last file for each month, not necessarily the file received on the last day of that month.
Lets say for Dec 2024 ideally the last file would be the one we receive on 31st of Dec but we may not have received a file on 31st and the last file we had received for this month was on 16th Dec. So file received on 16th Dec will become the last file of this particular month Dec 2024. So ideally for each month year the highest date will become the last file that we need to keep.
 
1.jpg
3.jpg
2.jpg
Categories:
I have the same question (0)
  • Suggested answer
    David_MA Profile Picture
    13,868 Super User 2026 Season 1 on at
    If you run the flow during the month after the file you need to get, add a filter query where Created is less than the value returned from this expression: formatDateTime(startOfMonth(utcNow()), 'yyyy-MM-dd'). Then set the order to Created desc and limit it to one file. That should give you the last file created in the folder.
     
  • CU06081659-0 Profile Picture
    128 on at
    Hi David MA,
     
    Its weird that I couldn't reply to your post and had comment on my post instead. Not sure what is happening with my Profile.
     
    The Flow will run everyday and it will only keep the latest file for the current month and for previous months it would keep the last file of those months. Now that last file may have been received on the last day or any other day but that would be the last file after which we didn't get any files. The entire exercise will have to be done on filenames which are in yyyy_MM_dd-ABCD EFGH formats

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 77 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 68

#3
Expiscornovus Profile Picture

Expiscornovus 56 Most Valuable Professional

Last 30 days Overall leaderboard