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 / list files in folder a...
Power Automate
Suggested Answer

list files in folder and order by date

(0) ShareShare
ReportReport
Posted on by 4
Having issues grabbing the files in the list and ordering by date. I am able to list the files in the folder but the compose step i came up with does not return anything
 
take(sort(body('List_files_in_folder'), 'LastModified', 'Descending') , 25)

Categories:
I have the same question (0)
  • Suggested answer
    Vish WR Profile Picture
    3,748 on at

    You need to sort the body array, not the entire action output. Try:



    take(
        reverse(
            sort(body('List_files_in_folder')?['body'], 'LastModified')
        ),
        25
    )
     

    sort() only sorts in ascending order, so reverse() gives you the latest files first. If your connector supports Order By, using LastModified desc is an even better option since the sorting happens at the source.



     
  • Suggested answer
    Ricky Dangi Profile Picture
    6 on at

    The issue is that you're trying to sort the entire response body instead of the array of files.

    The List files in folder action returns the files in the value array. Try sorting that array instead.

    For example:

    take(
        sort(
            body('List_files_in_folder')?['value'],
            'LastModified',
            'Descending'
        ),
        25
    )
    

    If this still returns no results, check the following:

    • Verify that LastModified is the correct property name returned by the action. Depending on the connector (OneDrive, SharePoint, etc.), it may be named LastModifiedDateTime, TimeLastModified, or something similar.

    • Add a Compose action with:

      body('List_files_in_folder')?['value']
      

      and inspect the output in the run history to confirm the available property names.

    • If you're using the SharePoint Get files (properties only) action, you can often avoid expressions altogether by using the built-in Order By field with:

      Modified desc
      

      which is more efficient than sorting after retrieval.

    If you can share which connector you're using (SharePoint, OneDrive, Azure Blob, File System, etc.) and a sample output from List files in folder, I can suggest the exact expression.

  • JN-30061816-0 Profile Picture
    4 on at
    yes this was helpful, but now i'm having an issue on getting file content 

  • JN-30061816-0 Profile Picture
    4 on at
    i did this but it's still picking up all the files instead of the top 25 

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard