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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
owlet0214
Helper I
Helper I

When the file name changes depending on the date

Hello, from Japan

 

If the file name changes depending on the date, can I fix it by modifying the code?

 

For example, in the case of today, an expression describing yesterday's date is placed. Get with the following query.

Excel.Workbook(Web.Contents("https://www.aaa.com/files/documents/worldwide-2020-06-28.xlsx"), null, true)

 

On the next day, change the file name and get it as follows.

Excel.Workbook(Web.Contents("https://www.aaa.com/files/documents/worldwide-2020-06-29.xlsx"), null, true)

 

I want to read "worldwide-*.xlsx" without any changes in the query editor.

 

Please help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

let

partDate=DateTime.ToText(Date.AddDays( DateTime.LocalNow(),-1), "yyyy-MM-dd"),

Origine = Excel.Workbook(Web.Contents("https://www.aaa.com/files/documents/worldwide-"& partDate & ".xlsx"), null, true)

 

in Origine

View solution in original post

8 REPLIES 8
Uno707
Frequent Visitor

Is there any thing you can do when the new date to the file is unknown? I.e. the file is named with the date it was updated however you don't know when the data source will be updated each time. 

MattAllington
Community Champion
Community Champion

What I normally do is this. 

select "load from folder" instead of load from file

don't combine the files, but click Transform

add a new column that extracts the date, convert it to a date

sort descending so it keeps the latest

load the top file (click binary, but then change the ref to be absolute ref to the first file). I normally do this by changing the code name="yada", Folder="something" and replace it with {0}



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

what if files are on Sharepoint? I use similiar techinque for folders on my drive and files on SP. however seems power query cannot connect to folder on SP? how to bypass this?

This is what worked for me. Wish I saw this sooner! 

Anonymous
Not applicable

try this:

 

let
partDate=DateTime.ToText(DateTime.LocalNow(), "yyyy-MM-dd"),

Origine = Excel.Workbook(Web.Contents("https://www.aaa.com/files/documents/worldwide-"& partDate & ".xlsx"), null, true)
in
Origine

Thanks!

 

But I get "worldwide-2020-06-29.xlsx ".

I want date of yesterday "worldwide-2020-06-28.xlsx"

Is it possible to get the date of the previous day?

 

 

Anonymous
Not applicable

let

partDate=DateTime.ToText(Date.AddDays( DateTime.LocalNow(),-1), "yyyy-MM-dd"),

Origine = Excel.Workbook(Web.Contents("https://www.aaa.com/files/documents/worldwide-"& partDate & ".xlsx"), null, true)

 

in Origine

Thnks so much!
Success!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors