Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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.
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?
Solved! Go to Solution.
- 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.
- 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.
Hi @nok
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.
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"
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.