Forum Discussion
Powe query repeating merge and name handling
- 6 months ago
Hi NewtoPQ25 ,
If, when you refer to 'new queries' and 'new query names' you mean the actual Power Query queries i.e. tables/table queries, then I don't think you're going to be able to do what you want to do here. As far as I'm aware, M code in Power Query CAN NOT spawn new table queries dynamically, nor can it edit table query objects, such as renaming them etc. M code works only within the query to which it relates, it can not perform actions outside of that query (within the scope of your request, anyway).
What (I think) you're describing is some sort of robotic process automation task which, though technically feasible I guess, certainly would not be something I'd be aiming at Excel or Power BI Desktop query editors to be honest.
...or, if I've completely misunderstood that bit, then probably the merge operation in List.Accumulate? If so, I'll leave it to jgeddes . They're a pro and they were also here first 🙂
Pete
Hi@BA_Pete, thank you so much for insightful comments. I think I read something as you mentioned there is something PQ does not do like dynamically assigning a name for a new merge. I wish I have asked earlier but I did learn a lot of PQ by trying to advance as much as I can.
Today after I posted this, I did try to fetch the first merge outcome using #section the Table.Last see if I can take that new table and as another merge, as this way I try to avoid assigning it a new nane. Still I found hard to navigate new table merged and what is in Last. I kind of get back to Excel to automate there. If needed I may use VBA.
But thanks, in deed!
Hi NewtoPQ25 ,
No problem, happy to help.
I would say that you should use the intrinsic identifiers (#section, #shared etc.) with extreme caution in Power Query. They aren't really designed to be used as part of a production transformation query and will fail refresh if you attempt to use them within PBI Service model/dataflow queries.
As I alluded to in my previous post, try looking into the List.Accumulate function in Power Query. It will perform 'loops' over lists etc. so might be able to do what I think you're asking within a single query. You would essentially feed it your parameter list and have it 'loop' over each value pair, performing a merge function on each iteration using the updated parameter pairs each time. I can't say at this point whether this will 100% do what you need, but it's where I would start looking if it were me.
List.Accumulate - PowerQuery M | Microsoft Learn
Also, don't forget to give a thumbs-up on any posts that have helped you along the way 🙂👍
Pete