Forum Discussion
Name a Table from a Column Value
- 1 year ago
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 Richard_Halsall Could you try this please
Group Data by Asset:
- Go to Home → Group By.
- In the Group By window:
- Group by the Asset column.
- Operation: All Rows.
Create a New Column for Table Names:
- Add a custom column to extract the Asset value as the table name:
- Go to Add Column → Custom Column.
- Use this formula:Text.From([Asset])
- Add a custom column to extract the Asset value as the table name:
- Iterate and Save Tables: For each row (grouped by Asset), you can extract the nested table and save it with the dynamic name. However, Power Query does not directly support exporting multiple tables automatically. You’ll need to:
- Go to each grouped table.
- Rename the query manually based on the new column.
Heres the M code
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