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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Help understanding query to add dynamic Date to file name

Hi all,

I'm very new to Power BI, so I hope I don't upset anyone here.

I'm trying to understand how to add a dynamic query to get a file as data source.

Most of the file name is constant, but a new file with the current date is generated every day and I want to target that updated file as the data source. Kind of a regex, right?

I googled and find out it's possible to use DateTime.Date in the query as part of the File name.

That should fix my problem.

However, I don't understand the query I generated and I don't know in where should I modify/add this.

This is my current query:

 

let
Source = AzureStorage.Blobs("storageaccountname"),
backupreportsxlsx1 = Source{[Name="containername"]}[Data],
#"https://storageaccountname.blob.core.windows.net/containername/_filename-14-11-19.xlsx" = containername1{[#"Folder Path"="https://storageaccountname.blob.core.windows.net/containername/",Name="filename-14-11-19.xlsx"]}[Con...],
#"Imported Excel" = Excel.Workbook(#"https://storageaccountname.blob.core.windows.net/containername/filename-14-11-19.xlsx"),
file_Table = #"Imported Excel"{[Item="file",Kind="Table"]}[Data]
in
file_Table

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

Hi @Anonymous ,

 

We can try to use the following formula to meet your requirement, the filename will try to generate the name "filename-day-month-year.xlsx"  of current day when refresh.

 

let
Source = AzureStorage.Blobs("storageaccountname"),
backupreportsxlsx1 = Source{[Name="containername"]}[Data],
filename = "filename-" 
		& Number.ToText(Date.Day(DateTime.LocalNow()))  
		& "-" & Number.ToText(Date.Month(DateTime.LocalNow()))
		& "-" & Number.ToText(Date.Year(DateTime.LocalNow()))
		& ".xlsx"
#"FileLocation" = containername1{[#"Folder Path"="https://storageaccountname.blob.core.windows.net/containername/",Name=filename}[Con...],
#"Imported Excel" = Excel.Workbook(#"FileLocation"),
file_Table = #"Imported Excel"{[Item="file",Kind="Table"]}[Data]
in
file_Table

 

Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Dong Li
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

2 REPLIES 2
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can try to use the following formula to meet your requirement, the filename will try to generate the name "filename-day-month-year.xlsx"  of current day when refresh.

 

let
Source = AzureStorage.Blobs("storageaccountname"),
backupreportsxlsx1 = Source{[Name="containername"]}[Data],
filename = "filename-" 
		& Number.ToText(Date.Day(DateTime.LocalNow()))  
		& "-" & Number.ToText(Date.Month(DateTime.LocalNow()))
		& "-" & Number.ToText(Date.Year(DateTime.LocalNow()))
		& ".xlsx"
#"FileLocation" = containername1{[#"Folder Path"="https://storageaccountname.blob.core.windows.net/containername/",Name=filename}[Con...],
#"Imported Excel" = Excel.Workbook(#"FileLocation"),
file_Table = #"Imported Excel"{[Item="file",Kind="Table"]}[Data]
in
file_Table

 

Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you for the help!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.