Forum Discussion
Custom Function works, but not when invoked with column names
- 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
Hi Anonymous ,
The conclusion seems to be that Power Query prevents us from using the reserved keyword to create the parameter names of the custom function.
Here is a similar case that you can refer to: Solved: error: Operation is not valid due to the current s... - Power Platform Community (microsoft.com)
Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous
Thanks for the reply. I can't see which word I'm using in my code could be a reserved keyword. I've renamed all my variables (including output) and still have the same issue