Forum Discussion
Recursive functions in dataflows
- 7 years ago
I Struggled with this for a while as well. It seems the solution is as simple as using an @ sign.
This is an example my coworker wrote.
let f = (n as number) as number => if n = 0 then 0 else if n = 1 then 1 else @f(n - 2) + @f(n - 1) in f
I've tested it and it works in dataflows. Note, when you make the recusive call, be sure to reference the name of the function from inside the let. For example, say the external name for this is 'fib', you need to make the recursive call with @f(..). I hope this helps!
Edit:
This is addressed on page 28 of the reference manual.
https://docs.microsoft.com/en-us/powerquery-m/power-query-m-language-specification
Hi Yep doing it in M with functions. These are working fine in Power BI desktop and when published to the service as a dataset. But in data flows just no luck. Maybe I need to rewrite the functions.
Thanks!
I Struggled with this for a while as well. It seems the solution is as simple as using an @ sign.
This is an example my coworker wrote.
let f = (n as number) as number => if n = 0 then 0 else if n = 1 then 1 else @f(n - 2) + @f(n - 1) in f
I've tested it and it works in dataflows. Note, when you make the recusive call, be sure to reference the name of the function from inside the let. For example, say the external name for this is 'fib', you need to make the recursive call with @f(..). I hope this helps!
Edit:
This is addressed on page 28 of the reference manual.
https://docs.microsoft.com/en-us/powerquery-m/power-query-m-language-specification