# Difference between 2 values in a table

**URL:** <https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262>\
**Category:** Need help\
**Created:** [January 3, 2024, 2:37pm UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262 "2024-01-03T14:37:42Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![jordiboy88001](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jordiboy88001/32/198726_2.png) [@jordiboy88001](https://forum.bubble.io/u/jordiboy88001)\
**Post date:** [January 3, 2024, 2:37pm UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262/1 "2024-01-03T14:37:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nico.dicagno](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/nico.dicagno/32/207961_2.png) [@nico.dicagno](https://forum.bubble.io/u/nico.dicagno)\
**Post date:** [January 3, 2024, 2:42pm UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262/2 "2024-01-03T14:42:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jordiboy88001](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jordiboy88001/32/198726_2.png) [@jordiboy88001](https://forum.bubble.io/u/jordiboy88001)\
**Post date:** [January 3, 2024, 2:53pm UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262/3 "2024-01-03T14:53:07Z")

</div>

Just display it

---

<div class="post-metadata">

**Author:** ![hergin](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/hergin/32/199185_2.png) [@hergin](https://forum.bubble.io/u/hergin)\
**Post date:** [January 3, 2024, 2:57pm UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262/4 "2024-01-03T14:57:08Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/6/1/61aa987f9c6875af5849b5ba3e4373667cfea3fc.png)

And the final result:  
 ![image](https://us1.discourse-cdn.com/bubble/original/3X/d/8/d835b5440a61d503e03dc1afe7bc15b4a82ac29d.png)

I have a data type called Data with value as a number in it:  
 ![image](https://us1.discourse-cdn.com/bubble/original/3X/a/0/a05bc5e990e9a4de47e58e6e864a554b840e033d.png)

---

<div class="post-metadata">

**Author:** ![jordiboy88001](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jordiboy88001/32/198726_2.png) [@jordiboy88001](https://forum.bubble.io/u/jordiboy88001)\
**Post date:** [January 3, 2024, 3:38pm UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262/5 "2024-01-03T15:38:37Z")

</div>

Thanks hergin!

---

<div class="post-metadata">

**Author:** ![jordiboy88001](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jordiboy88001/32/198726_2.png) [@jordiboy88001](https://forum.bubble.io/u/jordiboy88001)\
**Post date:** [January 3, 2024, 6:52pm UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262/6 "2024-01-03T18:52:00Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![hergin](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/hergin/32/199185_2.png) [@hergin](https://forum.bubble.io/u/hergin)\
**Post date:** [January 3, 2024, 7:53pm UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262/7 "2024-01-03T19:53:18Z")

</div>

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](https://us1.discourse-cdn.com/bubble/original/3X/3/6/3608094087b43bd3773cbd25bcc896745fb59913.png)

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/b/b/bb8cebd48bb59669fd1bb45cd9cf2cbf3b347cd9.png)

---

<div class="post-metadata">

**Author:** ![jordiboy88001](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jordiboy88001/32/198726_2.png) [@jordiboy88001](https://forum.bubble.io/u/jordiboy88001)\
**Post date:** [January 3, 2024, 8:13pm UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262/8 "2024-01-03T20:13:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hergin](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/hergin/32/199185_2.png) [@hergin](https://forum.bubble.io/u/hergin)\
**Post date:** [January 3, 2024, 9:54pm UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262/9 "2024-01-03T21:54:30Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/f/9/f9acc75d022ad70fe2fedca202267ce926f17177.png)

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/1/e/1e9d0fc03773ed8737b24c5a4fe40c76cf832b41.png)

---

<div class="post-metadata">

**Author:** ![jordiboy88001](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jordiboy88001/32/198726_2.png) [@jordiboy88001](https://forum.bubble.io/u/jordiboy88001)\
**Post date:** [January 3, 2024, 10:09pm UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262/10 "2024-01-03T22:09:02Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![hergin](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/hergin/32/199185_2.png) [@hergin](https://forum.bubble.io/u/hergin)\
**Post date:** [January 4, 2024, 3:51am UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262/11 "2024-01-04T03:51:29Z")

</div>

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](https://us1.discourse-cdn.com/bubble/original/3X/3/7/37a0dd44f827711fe31d8f0127fc27cce1702405.jpeg)

---

<div class="post-metadata">

**Author:** ![jordiboy88001](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jordiboy88001/32/198726_2.png) [@jordiboy88001](https://forum.bubble.io/u/jordiboy88001)\
**Post date:** [January 4, 2024, 1:15pm UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262/12 "2024-01-04T13:15:16Z")

</div>

Thanks so much !

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [March 13, 2024, 2:37pm UTC](https://forum.bubble.io/t/difference-between-2-values-in-a-table/300262/13 "2024-03-13T14:37:55Z")

</div>

This topic was automatically closed after 70 days. New replies are no longer allowed.
