Need help on expression rule for array calculation

Certified Senior Developer

I am having an array like {22,10,12,11, 8, 17}. I need an expression which return the index where individual array value or sum of previous values is greater than or equal to 20.

For example: The output should be {1, 3, 5, 6}.

22 (22-20) => 2 (index = 1)

2 (remainder from previous value) + 10 + 12 (24-20) => 4 (index = 3)

4 (remainder from previous value) + 11 + 8 (23-20) => 3 (index = 5)

3 (remainder from previous value) + 17(20-20) => 0 (index = 6) 

As there is no while/do-while loops in Appian so it seems bit difficult to get the desired output with foreach loop.

  Discussion posts and replies are publicly visible