Find the difference between each collection item in collection.

jaganrpa

New Member
I have a below collection,

Position
1
12
24
41
43

i need to find the difference of the each collection (i.e. 12-1, 24-12,41-24,43-41) and store in the data item.

Can u please guide me how to proceed.
 

sivagelli

Well-Known Member
Use a loop and have a data item say Count with initial value as 1; increment the count value before loop ends. Now, in the loop use this count value and a decision stage to check if the count is even number or odd. Based on that, store the value from collection in to data items and use a calc stage to perform substraction.
 

VJR

Well-Known Member
Hi jaganrpa,

You can use the 'Read Collection Field' action and pass the row index as Row x and Row x-1 until you reach the last row.
Here x is a running incremental counter.
Note that the collection row index starts from 0. So if you start from x=1 then based on the above equation you will get value of Row 1 and Row 0. ie; 1st and 2nd row of the collection. Subtract these two values, store it where you want and continue the same till x = last row. You can get the last row using the 'Count rows' action of Collections VBO (not Collection manipulation).
 
Top