Forum Discussion

nicolast29's avatar
nicolast29
Helper V
3 years ago
Solved

Dynamicly delete x line

Hi I have multiple Excel file to concatenate, but i should only start after that i found this  information Section 7 on a specific sheet. This information is not at the same line for each file I m...
  • lbendlin's avatar
    lbendlin
    3 years ago
    let
        Source = Folder.Files("C:\Users\xxx\Downloads"),
        #"Filtered Rows" = Table.SelectRows(Source, each [Name] = "ww.xlsx" or [Name] = "yy.xlsx" or [Name] = "ZZ.xlsx"),
        LoadFile = (Ex) => let
            #"Imported Excel Workbook" = Excel.Workbook(Ex),
            #"Fiche contrôle_Sheet" = #"Imported Excel Workbook"{[Item="Fiche contrôle",Kind="Sheet"]}[Data],
            #"Added Index" = Table.AddIndexColumn(#"Fiche contrôle_Sheet", "Index", 0, 1, Int64.Type),
            #"Removed Top Rows" = Table.Skip(#"Added Index",Table.SelectRows(#"Added Index", each ([Column2] = "Section 7 : RECOMMANDATIONS#(lf)"))[Index]{0}+1),
            #"Replaced Value" = Table.ReplaceValue(#"Removed Top Rows",null,"Category",Replacer.ReplaceValue,{"Column2"}),
            #"Removed Other Columns" = Table.SelectColumns(#"Replaced Value",{"Column2", "Column4"}),
            #"Promoted Headers" = Table.PromoteHeaders(#"Removed Other Columns", [PromoteAllScalars=true])
        in
            #"Promoted Headers",
        #"Added Custom" = Table.AddColumn(#"Filtered Rows", "DataCustom", each LoadFile([Content])),
        #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Name", "DataCustom"}),
        #"Expanded DataCustom" = Table.ExpandTableColumn(#"Removed Other Columns", "DataCustom", {"Category", "Thème"}, {"Category", "Thème"}),
        #"Filtered Rows1" = Table.SelectRows(#"Expanded DataCustom", each ([Thème] <> null))
    in
        #"Filtered Rows1"