If you have come to this page then you must have discovered by now that Azure Data Factory doesn’t allow you to assign a new value to the same variable in an expression i.e. self assignment is not possible inside the expression. This becomes relevant when you are implementing the loops and want to increment the variable within each iteration.
The workaround to achieve the same is to use two set of variables i.e. first increment a temporary variable and then assign this temporary variable to main variable keeping track of each iteration. Let’s see how we implemented this in a pipeline –
We created two variables – TempCounter as a temporary variable and then Counter, the main variable. Then, inside the Until loop, we used two set variable activities –
Since the variable is of string type so first this needs to be converted into integer and then need to be converted back to string.