# Data table calculation

**URL:** <https://forum.bubble.io/t/data-table-calculation/339811>\
**Category:** Database\
**Created:** [September 18, 2024, 12:26pm UTC](https://forum.bubble.io/t/data-table-calculation/339811 "2024-09-18T12:26:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dennisv24](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@dennisv24](https://forum.bubble.io/u/dennisv24)\
**Post date:** [September 18, 2024, 12:26pm UTC](https://forum.bubble.io/t/data-table-calculation/339811/1 "2024-09-18T12:26:03Z")

</div>

Hi,

For a data table I want to create a column where it calculates the current row count minus the previous row count.

So let’s say the first row shows the count 120 and the second row 130, the difference column I want to show 10…

Does someone have a idea of how the dynamic data would look like in a text field?

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [September 18, 2024, 12:33pm UTC](https://forum.bubble.io/t/data-table-calculation/339811/2 "2024-09-18T12:33:30Z")

</div>

Do you mean you want to do this in the database?

Or in a ‘table’ (or repeating group) on the page?

---

<div class="post-metadata">

**Author:** ![Baloshi69](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/baloshi69/32/136122_2.png) [@Baloshi69](https://forum.bubble.io/u/Baloshi69)\
**Post date:** [September 18, 2024, 12:43pm UTC](https://forum.bubble.io/t/data-table-calculation/339811/3 "2024-09-18T12:43:36Z")

</div>

I think he mean in table.

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [September 18, 2024, 12:46pm UTC](https://forum.bubble.io/t/data-table-calculation/339811/4 "2024-09-18T12:46:20Z")

</div>

In that case the expression will be:

`current row's thing's count - (Table's list of things: item# (current cell index - 1)'s count)`

---

<div class="post-metadata">

**Author:** ![Baloshi69](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/baloshi69/32/136122_2.png) [@Baloshi69](https://forum.bubble.io/u/Baloshi69)\
**Post date:** [September 18, 2024, 12:47pm UTC](https://forum.bubble.io/t/data-table-calculation/339811/5 "2024-09-18T12:47:56Z")

</div>

inside table let say the field is A in Database, which store the count.

in table text element user below condition

`Repeating Group ' item A - Repeating Group 'item current cell index + 1 'A`

so if current cell have 130 and previous cell have 120 = \> it gonna show 10.

If you still stuck, ping me, i would love to understand you situation and walk you through.

---

<div class="post-metadata">

**Author:** ![Baloshi69](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/baloshi69/32/136122_2.png) [@Baloshi69](https://forum.bubble.io/u/Baloshi69)\
**Post date:** [September 18, 2024, 12:49pm UTC](https://forum.bubble.io/t/data-table-calculation/339811/6 "2024-09-18T12:49:22Z")

</div>

Yah, we both are correct, but not depend on , either he want to minus from previous cell , or next cell 🙂

but i think you approach is better.

---

<div class="post-metadata">

**Author:** ![dennisv24](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@dennisv24](https://forum.bubble.io/u/dennisv24)\
**Post date:** [September 18, 2024, 12:52pm UTC](https://forum.bubble.io/t/data-table-calculation/339811/7 "2024-09-18T12:52:12Z")

</div>

I did see some forums talking about this solution…

The only thing is when I follow the steps I can’t go further than this: "Current row’s thing’s Number - " When adding the () the options are elements  
 ![Screenshot 2024-09-18 at 14.51.54](https://us1.discourse-cdn.com/bubble/original/3X/5/4/5427ae515b62ee7fd36b00ffd351e443d0607a3d.png)

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [September 18, 2024, 12:54pm UTC](https://forum.bubble.io/t/data-table-calculation/339811/8 "2024-09-18T12:54:23Z")

</div>

You don’t type “(” just use the expression builder - the parenthesis will be added automatically, assuming you have the parentheses feature enabled (which I _think_ you’ll need to do this).

---

<div class="post-metadata">

**Author:** ![dennisv24](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@dennisv24](https://forum.bubble.io/u/dennisv24)\
**Post date:** [September 18, 2024, 2:15pm UTC](https://forum.bubble.io/t/data-table-calculation/339811/9 "2024-09-18T14:15:50Z")

</div>

Finally after playing around I got it to work! Thank you for the great tip…
