Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

List.Generate from recursive loop

Hello PBI friends,   I would like to get help with the following. I'm creating a loop for the first time. It's working for the first pages, but at some time it's causing a stack overflow. Now I kno...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    There's a parctical example in the following blog, hope it can solve your problem:

    Recursive Functions in Power BI / Power Query — The Power User

    The recursive function

    fxTranslate = (x as table, n as number, ColName as text ) as table =>
    
           let
    
               Replace = Table.ReplaceValue(x, Old{n}, New{n}, Replacer.ReplaceText,{ColName}),
    Checking = if n = List.Count(Old)-1 then Replace else @fxTranslate(Replace, n+1, ColName )
    in
    Checking

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.