Aug 01 2019 08:07 AM
Aug 01 2019 08:07 AM
Aug 03 2019 01:26 AM
Hi @Deleted
Do you mean something like this...?
Aug 03 2019 05:12 AM - edited Aug 03 2019 05:15 AM
Aug 03 2019 08:19 PM
Aug 04 2019 07:34 AM
@Deleted
I'm not sure it's possible to make reference such way on any name, but it's possible to choose from predefined names, like
let
nIndex = 2,
Table1 = Table.FromRows({{1,2}},{"a","b"}),
Table2 = Table.FromRows({{3,4}},{"a","b"}),
Table3 = Table.FromRows({{5,6}},{"a","b"}),
// Select from environment
TableSelect = Expression.Evaluate("Table" & Number.ToText(nIndex),
[
Table1=Table1,
Table2=Table2,
Table3=Table3
]
),
// Select by function, but actually it's the same
TableSeletByFunction=SelectMyTable(3),
SelectMyTable =
let fnSelectTbl = (n as number) =>
let
tables = {
{1,Table1},
{2,Table2},
{3,Table3}
},
ReturnTable = List.First(List.Select(tables, each _{0}=n)){1}
in
ReturnTable
in
fnSelectTbl
in
TableSelect //TableSeletByFunction
If Table(i) are returned by another quires we may use #shared environment, when it's not necessary to predefine the list of existing tables.
Aug 04 2019 08:15 PM
@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
Aug 05 2019 02:30 AM
Aug 05 2019 04:31 AM
Aug 05 2019 10:59 PM
Aug 05 2019 11:06 PM
Aug 06 2019 01:55 AM
@Deleted , environment concept is explained, in particular, here https://blog.crossjoin.co.uk/2015/02/06/expression-evaluate-in-power-querym/ and https://ssbi-blog.de/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-3/
IMHO, that could be suitable if you use external queries for your tables, otherwise simple record approach which Wyn suggested is more preferable.