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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
nok
Advocate II
Advocate II

Filter only the most recent data in Power Query

Hi!
I have a folder where users upload Excel files with weekly data. All the files they upload have the same name and structure; the only thing that changes are the rows, as each file refers to a single week.

In Power Query, I want to connect only to the most recent file in this folder, based on the "Date created" date column. I want to dynamically bring only the data from the most recent file into Power BI. When the user uploads a new file for the next week, for example, the report should automatically bring only the data from the next week, as it will be the most recent data.

nok_1-1756931932754.png

So, based on the print above, the only row that should appear is the second one, where the date is 03/09/2025


How can I do this?

1 ACCEPTED SOLUTION
Shahid12523
Community Champion
Community Champion

- Connect to the folder with your files.
- Filter to only .xlsx files.
- Sort the files by Date created descending.
- Keep the top (most recent) file.
- Use its full file path to load the Excel data dynamically.

Shahed Shaikh

View solution in original post

3 REPLIES 3
Shahid12523
Community Champion
Community Champion

- Connect to the folder with your files.
- Filter to only .xlsx files.
- Sort the files by Date created descending.
- Keep the top (most recent) file.
- Use its full file path to load the Excel data dynamically.

Shahed Shaikh
danextian
Super User
Super User

Hi @nok 

 

  • Sort the Date created column in descending order.
  • Wrap the previous step in Table.Buffer to store the sorted data in memory: Table.Buffer(#"Previous Step Name")
  • Remove the Name column so that when accessing the first row from the Content column, the step won’t mistakenly reference the filename (which can change).
  • Go to Home > Keep Rows, and keep only the first row.
  • Under the Content column, click Binary.

danextian_0-1756952435015.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
MasonMA
Community Champion
Community Champion

Hello @nok 

 

On Power Query UI, you can sort 'descending' by 'Date created', keep only the top 1 row. This ensures only the latest file remains.

 

MasonMA_0-1756933271522.png

I'm using 'Date modified' in Demo, so the M code generated from UI would be 

let
    Source = Folder.Files("C:\"),
    #"Sorted Rows" = Table.Sort(Source,{{"Date modified", Order.Descending}}),
    #"Kept First Rows" = Table.FirstN(#"Sorted Rows",1)
in
    #"Kept First Rows"

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors