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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
joshua1990
Post Prodigy
Post Prodigy

Filter/ Source newest Excel File

Hello everyone!

I have a Sharepoint-Folder that contains for every week an Excel File.

This files have specific name like "SalesEDT202001012200"

Now I would like to extract/ source data just from the newest file.

How is this possible if there is always a new file with a new name?

 

Best Regards

 

1 ACCEPTED SOLUTION
ziying35
Impactful Individual
Impactful Individual

Hi, @joshua1990 

You can import from a folder, and then query the code like this:

 

let
    Source = Folder.Files("D:\temp"),
    splCol = Table.SplitColumn(
                 Source, 
                 "Name", 
                 each {_, DateTime.From(
                              Number.ToText(
                                  Number.From(Text.BetweenDelimiters(_,"SalesEDT",".xlsx")),
                                  "0000-00-00 00:00"
                              )
                          )
                       },
                {"Name", "DateTime"}
              ),
    filter = Table.SelectRows(splCol, let latest = List.Max(splCol[DateTime]) in each [DateTime] = latest)
in
    filter

I am following the example file name you provided to split the time text into real time values to form a new column, and finally by filtering the latest time to get the final file to be processed

 

If my code solves your problem, please mark it as a solution!

 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@joshua1990 , refer https://medium.com/@wkrzywiec/getting-data-from-the-latest-file-in-a-folder-using-power-query-51dfa4...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
ziying35
Impactful Individual
Impactful Individual

Hi, @joshua1990 

You can import from a folder, and then query the code like this:

 

let
    Source = Folder.Files("D:\temp"),
    splCol = Table.SplitColumn(
                 Source, 
                 "Name", 
                 each {_, DateTime.From(
                              Number.ToText(
                                  Number.From(Text.BetweenDelimiters(_,"SalesEDT",".xlsx")),
                                  "0000-00-00 00:00"
                              )
                          )
                       },
                {"Name", "DateTime"}
              ),
    filter = Table.SelectRows(splCol, let latest = List.Max(splCol[DateTime]) in each [DateTime] = latest)
in
    filter

I am following the example file name you provided to split the time text into real time values to form a new column, and finally by filtering the latest time to get the final file to be processed

 

If my code solves your problem, please mark it as a solution!

 

Fowmy
Super User
Super User

@joshua1990 

When you use GET DATA from Power Query, use Files From Folder. 
Apply the following filter to get the latest file like below.

image.png

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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