Forum Discussion
Anonymous
3 years agoNot applicable
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...
- 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 outputPat
ppm1
Solution Sage
3 years agoTry 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
Anonymous
3 years agoNot applicable
Amazing, Thank you!
I did think this morning it could be something like this where it's getting confused at the "input" values changing, but hadn't had chance to figure it out yet.