Forum Discussion

tross4012's avatar
tross4012
Icon for Helper I rankHelper I
4 years ago
Solved

Expression.Error due to variables in my query

I'm trying to add my [limit] variable to my [offset] variable. [offset] increases by the [limit] (which is hardcoded to 999) after each iteration. Can anyone enlighten me on what I'm doing wrong here? 

 

Expression.Error: 5 arguments were passed to a function which expects between 3 and 4.
Details:
Pattern=
Arguments=[List]

 

 

 

 

  • Sure thing, and it looks like you've already solved it in your second piece of code 🙂

     

    The solution is to Include MaxRank in the record in 1st and 3rd arguments, and it can therefore depend on other fields of the record that are updated in each iteration.

     

    Regards,

    Owen

3 Replies

  • HI tross4012 

    In your current code, the first argument of List.Generate is the source of the error.

    It appears that you have two "initial" arguments when there should only be one.

     

    If limit is a constant, I would define it outside List.Generate, and change the code to this:

    let
        limit = 999,
        Source = List.Generate(
            () => [offset = 1, getstudies = FnGetStudies( 1 )],
            each [offset] <= 411000,
            each [offset = [offset] + limit, getstudies = FnGetStudies( [offset] ) ],
            each [getstudies]
        )
    in
        Source

    Does this give you the result you expect?

     

    Regards,

    Owen

    • tross4012's avatar
      tross4012
      Icon for Helper I rankHelper I

      Hey Owen, 

       

      I really appreciate you taking the time to look at this. The issue I face is that I need the [limit] to equal [offset] + 999 after each iteration. 

      So if the [offset] is 1 on the fist iteration, the [limit] should be 1000 and so on. 

      I've changed [limit] to [MaxRank] as the use of "limit" might be misleading. [MaxRank] should not be a constant. 

      Is there any chance you see a way to do that in this code? Something like this:

       

      or 

       

       

      • OwenAuger's avatar
        OwenAuger
        Icon for Super User rankSuper User

        Sure thing, and it looks like you've already solved it in your second piece of code 🙂

         

        The solution is to Include MaxRank in the record in 1st and 3rd arguments, and it can therefore depend on other fields of the record that are updated in each iteration.

         

        Regards,

        Owen