Skip to main content

Hi everyone,

I’m new to Automation Anywhere and need help with writing logic to consolidate multiple records by summing their amounts.

I have a data file with several records following the same pattern but with different names. For example:

Alex Dan 145.33 

Alex Dan 1110.00

John Doe 200.50

John Doe 99.50

I want to merge duplicate entries into a single row by summing the amounts:

Alex Dan 1255.33 

John Doe 300.00

What is the best approach to achieve this in Automation Anywhere? Any guidance or sample bot logic would be greatly appreciated!

Thanks in advance!

Let me tag some folks to help you with this:

@Marc Mueller 

@LnMamou 

@amore17 

@sharath G 


Personally, I would do this kind of data manipulation in Excel. But, should you REALLY want to do this in Automation Anywhere, here’s how I would attack the problem:

1. I would use a List variable as an array for the names. This would allow me to quickly look through the names array (List variable) for the matching name and get the index. If one does not match, I would add it to the list and get the index of the added value.

2. Using the index from the name array, I would have another List variable for the totals. The index from the names variable would match the totals variable.

The challenging part is to ensure that you’re keeping the indexes of the two List variables (names and totals) in sync.

Once you’re done looping through all your entries, you can loop through the List variable (names) and using a counter for the index for totals, to export/display all the names/totals.

This could also be done with a single Data Table variable with two columns. If you really want to get fancy, you could do this with a Dictionary variable using the name as the index for the variable and using the variable itself to hold the total.

There are plenty of ways to accomplish this! Sounds like a fun exercise!


 Hi ​@satsup1421 ,

As per your request, I have tried implementing this from my end. Please review the code and let me know if you need any modifications or further support.

Currently, I only have access to the Community Edition, so I’m unable to export and upload it to the Bot Store. However, you can refer to the code in the screenshots attached.

Happy Automating! 😊

Input from text file
SumAmount code screenshot1
SumAmount code screenshot2

 

Final Output from List Variable

 


Reply