Forum Discussion

stribor45's avatar
stribor45
Post Prodigy
2 years ago
Solved

Execute n times

This code works for me fine but as I can not hard code n and i would know it from "some other code" how would I make this into a loop that would run n times?

 

//some other code
in
     result1,
     a = Query1{0}[list],
     b = Query1{1}[list],
     ......
     n = Query1{n}[list]
     c = List.Combine({a,b,...n})
in 
     c

 

 

 

  • What about this? Just change Number 100 to your n value - it can be stored also in [Column1] for example, so replace 100 with [Column1] if you add this as custom column.

     

     

    = List.Combine(List.Transform({0..100}, (n)=> Query1{n}[list]))

     

     

4 Replies

  • dufoq3's avatar
    dufoq3
    Community Champion

    What about this? Just change Number 100 to your n value - it can be stored also in [Column1] for example, so replace 100 with [Column1] if you add this as custom column.

     

     

    = List.Combine(List.Transform({0..100}, (n)=> Query1{n}[list]))

     

     

    • stribor45's avatar
      stribor45
      Post Prodigy

      just realized that my n is in //some other code  and not accessible in that part of the code

      • dufoq3's avatar
        dufoq3
        Community Champion

        If you mean in other query - in that case it is accessible.