Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How can I pick the latest file with Power Query?

Hello

 

How can I pick the latest file from a list of sharepoint files in a folder using Power Query?

 

Thanks!

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

The power query code is like this:

let
    Source = SharePoint.Files("https://xxx.sharepoint.com/sites/xxx", [ApiVersion = 15]),
    #"Filtered Rows" = Table.SelectRows(Source, let latest = List.Max(Source[Date modified]) in each [Date modified] = latest)
in
    #"Filtered Rows"

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can follow these steps to get the lastest file from Sharepoint folder:

1. Connect to Sharepoint folder, choose transfrom data

2. In power query, select the date modified column and filter it as 'Is latest'

lastest.png

3. Now you will get the lastest file content in power query, expand and import it into power bi to get the whole data.

 

Best Regards,

Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks but can you give me the Power Query for it please?

Hi @Anonymous ,

The power query code is like this:

let
    Source = SharePoint.Files("https://xxx.sharepoint.com/sites/xxx", [ApiVersion = 15]),
    #"Filtered Rows" = Table.SelectRows(Source, let latest = List.Max(Source[Date modified]) in each [Date modified] = latest)
in
    #"Filtered Rows"

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mahoneypat
Microsoft Employee
Microsoft Employee

You can do this with a relative reference instead of an absolute one to a specific file.  Please see this video and subscribe to that channel if you find it useful.

 

https://www.youtube.com/watch?v=nscUeOL5m90

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.