Forum Discussion
Anonymous
3 years agoNot applicable
How do I make this loop all children recursively?
Hello guys, i have a function ("flecheD") (ColChild,ColParent,ParentActuel,source)=>
let
mylist=Table.Column(Table.SelectRows(source,each Record.Field(_,C...
v-yanjiang-msft
3 years agoCommunity Support
Hi Anonymous ,
Please see if this document can help: Loops in Power Query M language (potyarkin.ml)
Best Regards,
Community Support Team _ kalyj
- Anonymous3 years agoNot applicable
Hi v-yanjiang-msft , thx for your suggestion. So I tried to create a custom function "SubChilldren" with List.Generate()
(children as text, ColChild,ColParent,source)=> let i = 1, length = Text.Length(children), subchildren = List.Generate( ()=>@flecheD(ColChild,ColParent,Text.At(children,i-1),source), i<=length, i+1 ) in Text.Combine(subchildren)which when coupled with my initial function
(ColChild,ColParent,ParentActuel,source)=> let mylist=Table.Column(Table.SelectRows(source,each Record.Field(_,ColParent)=ParentActuel),ColChild), resultat=Text.Combine(mylist) in Text.Trim( if resultat ="" then "" else if Text.Length(resultat) = 1 then @ resultat &"|" & @ flecheD(ColChild,ColParent,resultat,source) else @resultat &"|"& SubChildren(resultat,ColChild,ColParent,source),"|")should normally get the sub-children of each children. However, it still doesnt work ๐ . Could you please help me . Thx
@Gop01