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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

how to retrieve the most recent excel file stored in a folder of a Sharepoint ?

Hello,

I need to work with the latest file in a Sharepoint document folder.

The name of the Sharepoint site is let's say "https://myCompanySPurl/sites/SPSite" and the folder where my files are stored is let's say "myFolder".

The files stored in this folder follow this rule : myFile_YYYYMMDDHHMM.xls 

So when I mean that I must read the latest file, it must be based on the information within the filename and not the modified or creation date of the file itself or the date where it has been stored in the Sharepoint folder.

I also need to retrieve the date entered within the file name in order to display it in a card visual and provide information about the date to which the file's data corresponds.

Do you have any idea how to do that please ?

Regards,

Julien

1 ACCEPTED SOLUTION
edhans
Community Champion
Community Champion

Add a new column with this formula:

let varName = Text.BetweenDelimiters([File Name], "_", ".") in
#datetime(Number.From(Text.Start(varName, 4)), Number.From(Text.Middle(varName,5,1)), Number.From(Text.Middle(varName, 6, 2)), Number.From(Text.Middle(varName,8,2)), Number.From(Text.End(varName,2)),0)

It will give you this, and you can filter using the filters for Is Latest.

edhans_0-1678372865445.png

edhans_1-1678372892577.png

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

You could just split off the "myFile_, then change to number. Then you can just sort it descending and choose first row--seems like you can already just sort ascending--isn't that why you named the files in that format?

 

--Nate

edhans
Community Champion
Community Champion

Add a new column with this formula:

let varName = Text.BetweenDelimiters([File Name], "_", ".") in
#datetime(Number.From(Text.Start(varName, 4)), Number.From(Text.Middle(varName,5,1)), Number.From(Text.Middle(varName, 6, 2)), Number.From(Text.Middle(varName,8,2)), Number.From(Text.End(varName,2)),0)

It will give you this, and you can filter using the filters for Is Latest.

edhans_0-1678372865445.png

edhans_1-1678372892577.png

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

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