Forum Discussion

Anonymous's avatar
Anonymous
Aug 01, 2019

Power Query - String as Table name

Hi, In Power Query how can I call a Table name in a function by using a concatenated text sting. e.g : Table1 = Table.FromRows({{1,2}},{"a","b"}), Sufix = "Table" Index = "1" I want to refer to Table1 by using the string Suffix & Index or something like that.

11 Replies

    • Anonymous's avatar
      Anonymous
      Hi Wyn, thanks for your help. That works only whith the "Excel.CurrentWorkbook" function. My table isn't in a Excel Sheet. I need a query witch in is possible to select a table with a parameter as show in the eg attached. Where SelIndex is a parameter list (1,2,3). But in this eg, the query return only the table name, not the table.
      • Wyn Hopkins's avatar
        Wyn Hopkins
        MVP

        Deleted 

         

        Here's an option

         

        let
           
           MyTableRecord = [Table1 = Table.FromRows({{1,2}, {"a", "b"}}),
                            Table2 = Table.FromRows({{2,3}, {"a", "b"}}),
                            Table3 = Table.FromRows({{3,4}, {"a", "b"}})
                           ],
           TableSelect = Record.Field(MyTableRecord, "Table" & Text.From(SelIndex) )
        in
           TableSelect

         

        I have to thank Imke https://www.thebiccountant.com/ for this approach

         

         

Resources