Difference between 2 values in a table

Hi, happy new year!

I have a table with a column filled with values. I want to add a 2nd column and calculate for each row the difference between the value in the same row and the value of the row above (from the 1st column), how can I do that ?

Cheers

Do you want to save this new value to the database or do you just want to display it on a page?

Just display it

I was working on this a bit. Here is how you can do it and the final result:

And the final result:
image

I have a data type called Data with value as a number in it:
image

2 Likes

Thanks hergin!

What if I have a 3rd column in your exemple and I want to retrieve a cell in the second one ? How can i achieve this ?

You can do anything you want. Keep in mind that if the row doesn’t exist (for example, previous row doesn’t exist for the first row), then it will have default value (in my case, 0). The trick is in the calculation in the red circle:

image

I mean, all of this is related to the first column, how can you substract colum 2 to column 3 ?

The things that you see over there are not actual columns. They are just text field with some calculation in a repeating group cell. So, you can just use any combination of any “column”.

For example if you want to subtract column2 from column3, this is how you do it by just writing the formulas for both text fields and subtracting them.

Ok, pretty cool!
I can’t find “#current cell’s index +1’s value” for some reason, I only have “#current cell’s index’s value”, any idea why ?

I also recognized that. I guess it is not easy to do in the old expression editor. You should enable the experimental expression editor by clicking the button next to the name of the properties editor window.
1000011641

Thanks so much !