Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all,
I have a list of list like this:
Each list is composed by a table and a string, like this:
I want to write an M function that, for each list of the first photo, create a new table in the data model and give her name like the string in the list. For example, with the list above i want to create the new table with name "AZIENDA_GERARCHIA_010". I loop on each list with this code that is working fine:
Output = List.Transform(ListOfTables , each createTable(_))
The code of my createTable function is:
createTable = (l as list) => (
let
tableHierarchy = l{0},
nameTableHierarchy = l{1},
newTable = Table.FromRecords(Table.ToRecords(tableHierarchy))
in
newTable
)
But when i call createTable function, it create a new Source in the scope of the script! Not in my Data Model on Power Bi!
Instead, if i call createTable from button "Invoke", it creates a new table in the Data Model for each time i press on "Invoke".
My questions are:
Hello @Anonymous
I think there is no possibility to create with one query more tables, because one query can only have one result in form of a table. Also there is no possibility to change the query name within M
All the best
Jimmy
let
manyTabs = List.Transform({1..9}, each Table.FromValue(_)),
manyNames=List.Transform({"1".."9"}, each "tab"&_)
in
Record.FromList(manyTabs,manyNames)
@Anonymous I don't understand the solution, can you show me the content of the table tabs?
I don't know if this is a solution of your problem.
It is only a record having a list of key and as correnspondent values a list of tables.
@Jimmy801 ok but why when i call the same function with the button invoke it creates a new table?
just a guess,
may be this
Function.Invoke(function as function, args as list) as any
could makes what you want
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.