Forum Discussion
Dataflow/Dataset | Reading Incoming Fixed No. of column headers but Dynamic header name
Hi,
Source is an excel file and filename remains same for each month. For latest month file the data is pushed to column AE in excel and old month gets shifted to subsequent column and 16th month older gets dropped which was appearing in old file.
Can we read this kind of dynamic data from excel while keeping the first row as header?
We are encountering below error when we tried multiple options, the issue gets resolved when we reopen dataflow and save & close.
Error: Encountered user gateway exception: '[DM_ErrorDetailNameCode_UnderlyingErrorCode]=-2147467259 [DM_ErrorDetailNameCode_UnderlyingHResult]=-2147467259 [Microsoft.Data.Mashup.ValueError.Detail]=10-20 [Microsoft.Data.Mashup.ValueError.Reason]=Expression.Error [InnerType]=MashupValueException The column '10-20' of the table wasn't found.
Source code:
let
Source = Folder.Files(p_FilePath),
Navigation = Source{[#"Folder Path" = p_FilePath, Name = p_FileName]}[Content],
#"Imported Excel workbook" = Excel.Workbook(Navigation, null, true),
#"Navigation 1" = #"Imported Excel workbook"{[Item = "new sheet", Kind = "Sheet"]}[Data],
#"Changed column type" = Table.TransformColumnTypes(#"Navigation 1", {{"Column31", type text}, {"Column32", type text}, {"Column33", type text}, {"Column34", type text}, {"Column35", type text}, {"Column36", type text}, {"Column37", type text}, {"Column38", type text}, {"Column39", type text}, {"Column40", type text}, {"Column41", type text}, {"Column42", type text}, {"Column43", type text}, {"Column44", type text}, {"Column45", type text}, {"Column46", type text}}),
#"Promoted headers" = Table.PromoteHeaders(#"Changed column type", [PromoteAllScalars = true])
in
#"Promoted headers"
I am not sure if I framed the question correct. Any Suggestion to handle this dynamic nature of file?
Thanks,
Lokesh
2 Replies
- lbendlinSuper User
Avoid hardcoding column names. Instead use functions like Table.ColumnNames - PowerQuery M | Microsoft Docs
Provide sample files that illustrate the issue and indicate desired result.
- lraoRegular Visitor
lbendlin - Thank you for your response. Ofcourse we are not hardcoding it. Here are the samples - https://drive.google.com/file/d/13Lo7xQtWxkTqT49hKeW6H-MENiyFXSxm/view?usp=sharing
The file name remains XYZ-USAGE.xlsx each month but the month columns gets added and rearranged. Can we handle this kind of dynamic files but having first row as a columnname in dataflow?
Please note it should be scheduled refresh.