Recursion is a common coding pattern that involves a calculation being defined in terms of itself. While this may seem bizarre to non-coders, recursion is an extremely powerful coding pattern. Perhaps the most commonly known recursive example is the Fibonacci sequence. The Fibonacci sequence is defined like so: after the two starting numbers, 0 and 1, each number is the sum of the two preceding numbers. Mathematically, Fibonacci numbers are denoted as Fn and are defined formally as follows:
Regrettably, It is impossible to perform true recursion in DAX. In fact, DAX has logic that specifically prevents any type of recursive behavior. However, there are calculations that require recursive behavior, and thus this recipe provides a method for simulating recursion in DAX. Specifically, this recipe calculates the first six Fibonacci numbers.