Forum Discussion
Looping through reusable steps
- 4 years ago
Personally, I'd do this in DAX rather than Power Query. There are some nice PATH functions that make parent-child hierarchies fairly easy to work with. See here: https://www.daxpatterns.com/parent-child-hierarchies/
Solving this in Power Query is also possible but I need to think about it a bit more.
For your end result, do you really want a bunch of new columns or are they helper columns to compute the next step and you intend to discard or ignore them once you're done?
- ferryv4 years agoResolver II
They are helper columns that I remove at the end and used them to test that the data was running through the process ok.
- ferryv4 years agoResolver II
The Table.AddColumn was also more to illustrate what I am attempting to achieve, rather than the actual function, where I replace values in existing columns.
The main issue I'm attempting to resolve is using the last step in the loop as the start of the next iteration to avoid copying/pasting steps or using a separate function, which might cause a external source error once published.
- AlexisOlson4 years agoSuper User
You might be able to do dynamic step naming using Expression.Evaluate somehow, but it's unlikely that will be a good solution. It's really hard to tell without knowing what you're actually trying to do though.
List.Generate is pretty powerful itself without that sort of thing. If you can create a specific example and desired output, I'll give take a look.