Loading the latest version of a file
Sometimes only the latest version of a file matters. One example is a transaction file that grows each time it is sent, and another is a lookup table, such as a customer list, that changes slowly over time.
This page shows how to load just the latest version, while the older ones are kept.
Connect to the folder, not the file
Section titled “Connect to the folder, not the file”The trick is to connect to the folder that holds the file, rather than to the file itself:
- Give each version a name of its own, such as myFile-YYYYMMDD.xlsx.
- Save every version in the same folder.
- In Power Query, sort the folder’s files by creation date, newest first.
- Take the first file in the sorted list.
The query then loads only the newest version, and the folder keeps a history of all the earlier ones.

In this example, the file grows each day. The version from 18 October holds one day of data:

The version from 19 October holds two days of data:

1. Connect to the folder
Section titled “1. Connect to the folder”- On Excel’s Data tab, choose Get Data ➔ From File ➔ From Folder, and browse to the folder.

Power Query lists the files in the folder, with their names, extensions and dates:

- Click Transform Data.
2. Take the newest file
Section titled “2. Take the newest file”- Sort the Date created column in descending order, so that the newest file comes first.

- Click the fx button beside the formula bar, and enter this formula:
= Excel.Workbook(#"Sorted Rows"{0}[Content])#"Sorted Rows"{0} picks the first row of the sorted list, [Content] takes that file’s contents, and Excel.Workbook opens them as a workbook, which lists the sheets inside it.
- Rename the step SelectFirstRow.

- Click Table in the Data column to open the sheet.
- On the Transform tab, click Use First Row as Headers.
The query now returns the contents of the newest file:
