How to calculate the difference between rows that follow each other

I have data in the “balance” column.
How can I write a formula for the “Balance Difference” column so that the numbers are calculated automatically?

Hi! There is a solution based on Row Index

1 Like

I don’t see how that can be. I copied your formula completely, but it doesn’t work correctly for me :frowning:

Just copy the table in its entirety and use it)

I forgot to attach the link)

hi @Tamerlan_Kagarmanov , the rowIndex works and as an often applied solution. However did you consider to base your solution on the date (the month in the year)? that one permits for resorting the view. Cheers, Christiaan

1 Like

Yeah, that’s a great tip. However, I gave out the solution that first came to mind) There are actually many ways. Here I’ve gone with the simplest one. Just a linear algorithm.

indeed it depends on what you want, I created the one below, it requires a date field instead of the row index. It is always about comparing higher with lower numbers, be an integer or a date (which is a number under the hood as well).

  thisRow.Balance - previousMonth.Balance

cheers, christiaan


Yeah, it’s a great solution! Especially in accounting for finances

1 Like

@Tamerlan_Kagarmanov , @Christiaan_Huizer
I’m very grateful to you. I really struggled with this question for a long time, you helped me a lot.
I have only one question left, considering that you answer me so quickly and efficiently, I will write it here, maybe you will solve the problem that I have been puzzling over for a month.
I have a catalog of products with their price and availability in stock.
I have assembled elements from these products, for each product goes a certain number of elements from the catalog.
And here is the main problem. I need to make a table for the client, in which I will select one of the elements and put its multiplier.
For example. Element 001 consists of 20 units of fabric and other parts. And the customer orders 5 such elements (total 100 units of fabric) and so on.
I need the customer to first select an item and all its parts are added to the estimate, and then they go back to the catalog and subtracted from the total.

I got to the point that it is necessary to have a collection table, but I can not transfer a group of products and can not get then with a factor to link them to the catalog to see how much product is left :frowning:

That’s genius! Thank you!

1 Like