Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hi
Is there a way to name a table based on a column value in that table
I have a grouped table of data as below named AssetActivity
In a new query I have this code
let
Source = if Table.RowCount(AssetActivity) >= 1 then AssetActivity{0}[AllData] else null,
which creates a table named Asset1 with all data from the inner table named 'AllData'
I manually create a new query for each row and end up with 26 tables named Asset1.....Asset26
Is there anyway I can name the table 'T-33_441' rather than it being names Asset1 i.e. the value in the column named Asset present in the AssetActivity table
If it helps the Asset column is also present in the inner table
Any help would be appreciated. Thanks
Solved! Go to Solution.
I can not reproduce your behaviour. The code snippet you gave is not complete, so I guess there is more happening.
BUT,
You will always have to manuall create a new query for each row.
Given that...
Starting with:
Rightclick on the Table in any line and "Add as New Query
Will produce this new query:
Did I answer your question? Then please (also) mark my post as a solution and make it easier to find for others having a similar problem.
Remember: You can mark multiple answers as a solution...
If I helped you, please click on the Thumbs Up to give Kudos.
Kees Stolker
A big fan of Power Query and Excel
Still not entirely sure what you want to achieve, but NO, you can not rename a query by code on PowerQuery.
If you are working in Excel, you CAN use VBA to rename queries, but you will not hav access to the query results in VBA...
Kees Stolker
A big fan of Power Query and Excel
I can not reproduce your behaviour. The code snippet you gave is not complete, so I guess there is more happening.
BUT,
You will always have to manuall create a new query for each row.
Given that...
Starting with:
Rightclick on the Table in any line and "Add as New Query
Will produce this new query:
Did I answer your question? Then please (also) mark my post as a solution and make it easier to find for others having a similar problem.
Remember: You can mark multiple answers as a solution...
If I helped you, please click on the Thumbs Up to give Kudos.
Kees Stolker
A big fan of Power Query and Excel
Hi
So the code I provided allows me to create a new query for each row, what I am trying to achieve, as this file is a template file to be distributed to colleagues, if I create 8 new queries named Query 1, Query 2, Query 3 etc can I rename the query using code to the value in the column named asset
e.g. Query 1 renamed to T-16 441 using code
Thanks
Hi @Richard_Halsall Could you try this please
Group Data by Asset:
Create a New Column for Table Names:
let
Source = YourDataTable,
GroupedData = Table.Group(Source, {"Asset"}, {{"AllData", each _, type table [Column1=type, Column2=type]}}),
NamedTables = Table.AddColumn(GroupedData, "TableName", each "Table_" & Text.From([Asset])),
Result = Table.TransformColumns(NamedTables, {"AllData", each Table.RenameColumns(_, {"Asset", "RenamedTable"})})
in
Result
If this post helped please do give a kudos and accept this as a solution
Thanks In Advance