Forum Discussion

fab's avatar
fab
Helper I
9 years ago
Solved

Load only Excel tabs based on certain value

Hello, I have an Excel file with many tabs. I would like to load (Power BI desktop) automatically tabs that contain a certain value in theirs names. How can I do that ? Thank for your hel...
  • Datatouille's avatar
    9 years ago

    Ok,

    So try this: Open the Query Editor, copy/paste the following M code (advanced editor) and adapt the green part.

     

    let
        Source = Excel.Workbook(File.Contents("YourExcelFileFullPath"), true, true),
        KeepCol = Table.SelectColumns(Source,{"Name", "Data"}),
        Test = Table.AddColumn(KeepCol, "Flag", each Text.Contains([Name],"YourTestWord")),
        KeepTrue = Table.SelectRows(Test, each ([Flag] = true)),
        Expand = Table.ExpandTableColumn(KeepTrue, "Data", {"Column1", "Column2", "Column3", "Column4", "Column5"}, {"Column1", "Column2", "Column3", "Column4", "Column5"})
    in
        Expand