Forum Discussion
Dynamic Filename
- 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"
Hi Akash_Varuna thank you for the reply, but when I try i m getting some error. below my complete editor
let
Source = Excel.Workbook(Web.Contents("https://Company.sharepoint.com/sites/EASTWEST/Shared%20Documents/General/East%20West%20Current%20Active%20List%20(CAL)/2025%20Active%20WON%20List%20WK12.xlsx"), null, true),
#"Asset_Sheet" = Source{[Item="Asset",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(#"Asset_Sheet", [PromoteAllScalars=true]),
#"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"
Thank you
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"- AllanBerces1 year ago
Post Prodigy
Hi Akash_Varuna Anonymous Thank you very much for the reply. all good working as i need.