Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Custom Function works, but not when invoked with column names

I have written a custom function, that works perfectly when passed values directly, but when invoking it on my table and passed the same information via table columns says "Unexpected error: Operatio...
  • ppm1's avatar
    3 years ago

    Try using this version of your function instead. It avoids reusing the inputs as variables inside the function.

     

    (inputTotalLoops as number, inputLoopNumber as number, inputCurrentValue as text, inputEndValue as text) =>
    let
        varTotalLoops = inputTotalLoops,
        varCurrentLoop = inputLoopNumber +1,
        varEndValue = inputEndValue & Text.From(Number.From(inputCurrentValue)-1) & "/" & inputCurrentValue & ",",
        varCurrentValue = Text.From(Number.From(inputCurrentValue)+1),
        output =
        if varCurrentLoop >= inputTotalLoops
        then Text.Start(varEndValue, Text.Length(varEndValue)-1)
        else @testFunction1(varTotalLoops, varCurrentLoop, varCurrentValue, varEndValue)
    in
        output

     

    Pat