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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
Deevo_
Resolver I
Resolver I

Importing excel data by Filename partial match of the first 13 char, then import the latest modified

Hi All,

  • I have a report that uses an excel file as a datasource. 
  • The excel file lives in a folder with many other excel files with different filenames.
  • I have to manually copy and paste this file in another folder and point my report to that folder to import the "latest modified" excel file.

Question:

  • I am trying to streamline things abit and wanted to know if there is anyway to search all filenames within a folder and pick all the excel file with the same first 13 characters in the filename and then only use the "latest modified" file as my datasource?
  • Example:
    • Step 1: search all excel filenames starting with 'Timesheet Raw%'
    • Step 2: Sort by Date Modified Descending
    • Step 3: Only keep the first file from the search results
    • Step 4: Then add all my transformations

Thanks!

 

2 ACCEPTED SOLUTIONS
mlsx4
Memorable Member
Memorable Member

I think you can add the steps in the Power Query editor without any problem:

 

  1. Connect to folder as datasource and go to the first step in the editor. You will get something like this:mlsx4_0-1689147264482.png

     

  2. Filter rows by extension (xlsx o xls maybe)
  3. Filter name of file in the column -> Filter by text -> Starts whit...
  4. Once filtered, order by DESC date
  5. Keep the first row.

View solution in original post

Nithinr
Resolver III
Resolver III

let
Source = Folder.Files("\\Filepath"),
#"Filtered Rows" = Table.SelectRows(Source, each ([Extension] = ".xlsx")),
#"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each Text.StartsWith([Name], "Timesheet Raw")),
#"Sorted Rows" = Table.Sort(#"Filtered Rows1",{{"Date modified", Order.Descending}}),
#"Kept First Rows" = Table.FirstN(#"Sorted Rows",1)
in
#"Kept First Rows"

 

After this you need to expand content to get that excel data

View solution in original post

3 REPLIES 3
Deevo_
Resolver I
Resolver I

Thanks to both @Nithinr and @mlsx4 

This worked perfectly!

Much appreciated!

Nithinr
Resolver III
Resolver III

let
Source = Folder.Files("\\Filepath"),
#"Filtered Rows" = Table.SelectRows(Source, each ([Extension] = ".xlsx")),
#"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each Text.StartsWith([Name], "Timesheet Raw")),
#"Sorted Rows" = Table.Sort(#"Filtered Rows1",{{"Date modified", Order.Descending}}),
#"Kept First Rows" = Table.FirstN(#"Sorted Rows",1)
in
#"Kept First Rows"

 

After this you need to expand content to get that excel data

mlsx4
Memorable Member
Memorable Member

I think you can add the steps in the Power Query editor without any problem:

 

  1. Connect to folder as datasource and go to the first step in the editor. You will get something like this:mlsx4_0-1689147264482.png

     

  2. Filter rows by extension (xlsx o xls maybe)
  3. Filter name of file in the column -> Filter by text -> Starts whit...
  4. Once filtered, order by DESC date
  5. Keep the first row.

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.