This work flow is querying data from another list to summarize total numbers in each month for different segment.



Notes for workflow:
- 1. Perform a list item query on US Safety Metrics Monthly Data Entry and store result in colRecordMonth.
- 2. Remove duplicate values in colRecordMonth and store result in uniqueRecordMonth.
- 3. Loop through each item in uniqueRecordMonth and store result in tempRecordMonth.
- 5. Perform a list item query on US Safety Metrics Monthly Data Entry and store result in colRecordableCases.
- 6. Set variable totRecordableCases to equal 0.
- 7. Set variable totID to equal 0.
- 8. Loop through each item in colRecordableCases and store result in tempRecordableCases.
- 9. Do calculation:
totRecordableCases = totRecordableCases + tempRecordableCases. - 10. Perform a list item query on US Safety Metrics Monthly Data Entry and store result in colDARTCases.
- 11. Set variable totDARTCases to equal 0.
- 12. Set variable totID to equal 0.
- 13. Loop through each item in colDARTCases and store result in tempDARTCases.
- 14. Do calculation:
totDARTCases = totDARTCases + tempDARTCases. - 15. Perform a list item query on US Safety Metrics Monthly Data Entry and store result in colMan-hoursWorked.
- 16. Set variable totMan-hoursWorked to equal 0.
- 17. Set variable totID to equal 0.
- 18. Loop through each item in colMan-hoursWorked and store result in tempMan-hoursWorked.
- 19. Do calculation:
totMan-hoursWorked = totMan-hoursWorked + tempMan-hoursWorked. - 20. Perform a list item query on US Safety Metrics Overview and store result in colID.
- 21. Count the number of items in colID.
- 22. Variable 'totID' equals '0'.
- 23. Create Item in US Safety Metrics Overview.
- 24. Variable 'totID' not equals '0'.
- 25. Update an item in US Safety Metrics Overview.
First run result:

Second run result:

The second run result erase ID130 from ATS but add ID130 to AS as a duplicated record.
Can anyone help to find out where is incorrect on the workflow please?
Thanks,