Datatables and Excel Practice 2: Calculating Loss Invoices

The goal of this practice is to check which of the invoices in an Excel file were issued to clients in bankruptcy and calculate the sum of the invoices to be recorded as loss.

I was able to get the data from the two excel files and use the Join Data Tables and Filter Data Tables Activity. After that, I was using a For Each Row and I was going to create a new variable for the total loss.

The solutions said the following:
To calculate the loss from the companies that are bankrupt, loop through the rows in the filtered Data Table and add the content of the “InvoiceValue” column, converted to Integer, t­­­o a variable in which we will store the sum - “TotalLoss” of Integer type. Use a ‘For Each Row’ and an ‘Assign’ activity in the Body with the following method: TotalLoss = TotalLoss+Cint(row(“InvoiceValue”));

I don’t understand how we can use TotalLoss = TotalLoss + something else? Can someone clarify this for me?

Hi,

This is been done to carry forward the loss to next transaction as well…

Let’s say we have 3 invoice items with losses as below
1 500
2 300
3 200

At the first the default value of loss would be 0
In the first iteration
Total loss = Total loss+500
Total loss = 0+500
Total loss = 500
Second iteration
Total loss= Total loss +300
Total loss = 500+300. You can see it is being carry forward
Total loss = 800
Third iteration
Total loss= Total loss +200
Total loss = 800+200. You can see it is being carry forward
Total loss = 1000

Hope this clarifies!

That makes so much sense! Thank you so much :grinning:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.