How to Automatically Use the Newest Daily Source File in Power Query
Question details
The user needs to configure Power Query to dynamically select and load the most recently created daily source file instead of relying on a fixed filename.

- Product
- Power Query
- Device & OS
- not provided
- Scenario
- Automating daily data imports where a new source workbook is generated each day with a changing, date-based filename.
- Observed behavior
- Power Query continues loading the original workbook because the file path is hardcoded, failing to detect or load the newly created daily file automatically.
Ensure all your daily source files are stored in a single, dedicated folder and share a consistent file extension or naming convention.
Build a Dynamic Folder Query to Extract the Latest File
Instead of linking directly to a specific workbook, point Power Query to the folder containing the files, then dynamically sort by date to isolate the newest file.
By default, Power Query hardcodes the exact file path when importing from a file. Changing the source to 'From Folder' allows you to evaluate file metadata (like modified date) before extracting the actual data.
Open Excel, go to the Data tab, click on 'Get Data', select 'From File', and choose 'From Folder'. Browse to the folder containing your daily source files and click OK.
In the preview window that appears, do not click Load. Instead, click 'Transform Data' to open the Power Query Editor.
In the Power Query Editor, click the drop-down on the 'Extension' column to filter for your specific file type (e.g., .xlsx). You can also apply text filters to the 'Name' column if you need to match a specific daily naming pattern.
Locate the 'Date modified' (or 'Date created') column. Click the drop-down arrow on the header and select 'Sort Descending'. This action ensures the newest file is always placed at the top of the table.
Navigate to the Home tab on the ribbon, click 'Keep Rows', and select 'Keep Top Rows'. Enter '1' in the dialog box and click OK. Now only the most recent file remains in the list.
Click the 'Combine Files' icon (two downward-pointing arrows) on the 'Content' column header to extract the data from this single newest file. Complete any further data transformations you need, then click 'Close & Load'.

Looking for a Lightweight and Cost-Effective Alternative to Excel?
If complex data queries and expensive Excel licenses are slowing you down, consider switching to WPS Office. It provides robust spreadsheet tools, intuitive interfaces, and comprehensive data analysis capabilities completely free of charge.

Frequently Asked Questions
Why is Power Query loading an old file instead of my new daily file?
When you use the 'Get Data From File' option, Power Query hardcodes the exact filename and path. If a new file is created with a new date suffix, the query won't detect it automatically unless you configure the source to look at the entire folder instead.
Can I filter the newest file by date created instead of date modified?
Yes. In the Power Query Editor, you can choose to sort descending on the 'Date created' or 'Date accessed' column instead of 'Date modified', depending on how your daily files are generated and saved.
What happens if there are other files in the same source folder?
To prevent errors from non-related files, it is highly recommended to filter the folder contents by file extension (e.g., keeping only .xlsx) and specific naming conventions (using text filters on the file name) before applying the descending date sort.
How do I update the data after setting up the dynamic folder query?
Once configured, simply place your new daily file into the designated folder, open your main Excel workbook, and click 'Refresh All' on the Data tab. The query will automatically locate and load the latest file.




