Forum Discussion
AllanBerces
Post Prodigy
1 year agoDynamic Filename
Hi good day, can anyone help me on my PQ, the name of my data source change every week.. WK12..WK13 and so on. I want it to be dynamic.Can anyone help me to edit my PQ. let Source = Excel.Workb...
- 1 year ago
Hi AllanBerces Have you used the code that provided ? Maybe you have used but i couldnt see any ways could you try this please
let // Get the current week number (WK12, WK13, etc.) CurrentWeek = "WK" & Text.PadStart(Text.From(Date.WeekOfYear(DateTime.LocalNow(), Date.FirstDayOfWeek.Monday)), 2, "0"), // Construct the full file path dynamically FilePath = "https://company.sharepoint.com/sites/EASTWEST/Shared%20Documents/General/East%20West%20Current%20Act..." & CurrentWeek & ".xlsx", // Load the file from SharePoint Source = try Excel.Workbook(Web.Contents(FilePath), null, true) otherwise error "File for " & CurrentWeek & " not found. Please check the file path or week logic.", // Access the 'Asset' sheet #"Asset_Sheet" = Source{[Item="Asset",Kind="Sheet"]}[Data], // Promote headers #"Promoted Headers" = Table.PromoteHeaders(#"Asset_Sheet", [PromoteAllScalars=true]), // Change column types #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers", { {"WON", Int64.Type}, {"Location", type text}, {"Complex/#(lf)Outstation", type text}, {"Order Type", type text}, {"Discpline", type text}, {"Description", type text}, {"Asset Cat. Tool (ACT)", type text}, {"BSP Turnaround", type text}, {"Execution Window", type any}, {"BSP Estimate", Int64.Type}, {"Est. hrs", type number}, {"Active/#(lf)Inactive", type text}, {"FWL", type text}, {"INJECTED", type any}, {"PENDING #(lf)CI", type text}, {"DEFERRED/#(lf)CANCELLED", type text} }) in #"Changed Type"
Anonymous
1 year agoNot applicable
Hi AllanBerces
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.