Getting ready

To prepare for this recipe, do the following:

  1. Open Power BI Desktop.
  2. Create a new table called R11_Table using the following code:
R11_Table = { "Value" }

The R11_Table table is just here to serve as a place to create our measures. Let's also get ready for this recipe by quickly  reviewing loops. We start by reviewing the while loop. A while loop in most programming languages looks similar to the following:

int i=10;
int j=0
while(i>1) {
j=j+10
i=i-1;
}

In this pseudo-code, we declare a variable, i, and set the starting value for i to 10. We also declare a variable called j and set the starting value for j to 0. We then have the declaration of our while loop header, where we specify that we want to continue iterating only while the i variable is greater than 1. The body of the while loop is encapsulated by brackets: { and }. In this body, we add 10 to the value of j each time we go through the loop and we decrement i by 1. Thus, we would expect this loop to iterate nine times and for the value of j to be 90 once the loop finishes execution.