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
Anonymous
Not applicable

Dynamic Excel name handling in Power BI

I have a excel sheet named as ProductSales_YYYYMMDD.xls. and placed in a folder location.

 

Everyday in the same folder a new excel sheet get placed with current date. The new files will be in same column structure.

 

Now how to handle this scenario in Power BI for accepting new files every day with different name and same structure.

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi,  @Anonymous 

 

Yes, you can use 'Date.ToText( Date.From(DateTime.LocalNow()),"YYYYMMDD")' to select files dynamically.

Try like this in PQ :

 

 

 

let
    Source = Folder.Files(root&"FolderName"),
    temp = "ProductSales_"&Date.ToText(Date.AddDays( Date.From(DateTime.LocalNow()),1),"YYYYMMDD"),
    #"Filtered Rows" = Table.SelectRows(Source, each Text.Contains([Name],temp)),
    custom = Table.Max(#"Filtered Rows","Name")[Content],
    #"Imported Excel" = Excel.Workbook(custom),
    Table1_Table = #"Imported Excel"{[Item="Table1",Kind="Table"]}[Data]
in
    Table1_Table

 

 

 

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-janeyg-msft
Community Support
Community Support

Hi,  @Anonymous 

 

Yes, you can use 'Date.ToText( Date.From(DateTime.LocalNow()),"YYYYMMDD")' to select files dynamically.

Try like this in PQ :

 

 

 

let
    Source = Folder.Files(root&"FolderName"),
    temp = "ProductSales_"&Date.ToText(Date.AddDays( Date.From(DateTime.LocalNow()),1),"YYYYMMDD"),
    #"Filtered Rows" = Table.SelectRows(Source, each Text.Contains([Name],temp)),
    custom = Table.Max(#"Filtered Rows","Name")[Content],
    #"Imported Excel" = Excel.Workbook(custom),
    Table1_Table = #"Imported Excel"{[Item="Table1",Kind="Table"]}[Data]
in
    Table1_Table

 

 

 

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PC2790
Community Champion
Community Champion

As @Pragati11  mentione,d you wouldneed to go for folder approch.

You M query would look like something like this:

 

Source = Folder.Files(root&"FolderName"),
#"Filtered Rows" = Table.SelectRows(Source, each Text.StartsWith([Name], "ProductSales_"))

As the structuring and columns of all the files are same, you can go for merging all the files as per your requirement

Pragati11
Super User
Super User

Hi @Anonymous ,

 

You can use folder approach in Power BI as a solution for this. Refer the following article:

https://powerbi.tips/2016/06/loading-data-from-folder/

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

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 Solution Authors