Specifiying part of the file name as a variable

Viewed 55

good day all and thanks in advance for your help. begginer here, i am tryin g to insert a variable as part of a file name of a query i did in excel but i can't seem to find the correct syntax for it. appreciate your help.

= let
    WeekNum = Number.ToText(Date.WeekOfYear(Date.From(DateTimeZone.From(DateTime.LocalNow())))-1),
    Source = Excel.Workbook(File.Contents("C:\Users\Vendor Performance Alarm-Monitoring_Week ***[WeekNum]***_2019.xlsx"), null, true),
2 Answers

The file path is a string, so you can use concatenation.

...Vendor Performance Alarm-Monitoring_Week" & WeekNum & "_2019.xlsx...

Just replace step Source:

Source = Excel.Workbook(File.Contents("C:\Vendor Performance Alarm-Monitoring_Week"
 & WeekNum & "_2019.xlsx"), null, true)
Related