Forum Discussion
DJPrometheus
5 years agoMicrosoft Employee
Reflexive Table Reference
Can a table in a Power Query/M reference itself? E.g. populate a column with the name of the current table through Add Custom Column?
- 5 years ago
No DAX is involved at all. This is the Power Query language M.
The code I gave is what you would use in the Advanced Editor to define your combined query. The whole thing would look something like this:let Source = Table.FromColumns({{#"BMX Bikes", #"Mountain Bikes", #"Hybrid Bikes"}, {"BMX Bikes", "Mountain Bikes", "Hybrid Bikes"}}, {"Table", "ItemType"}), #"Expanded Table" = Table.ExpandTableColumn(Source, "Table", {"Serial", "Status", "Shipped"}, {"Serial", "Status", "Shipped"}) in #"Expanded Table"
AlexisOlson
5 years agoSuper User
Even if it's possible, it seems like it might not necessarily be a good idea. Generally, you don't want the result of the query to change if you rename it.
I can't think of a way to do this without self-reference errors but maybe there's an alternative for your ultimate goal. What is the motivation for wanting to do this?