# Sum list from local DB

**URL:** <https://community.thunkable.com/t/sum-list-from-local-db/602856>\
**Category:** Questions about Thunkable X\
**Created:** [June 8, 2020, 4:37pm UTC](https://community.thunkable.com/t/sum-list-from-local-db/602856 "2020-06-08T16:37:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![oreeldadln](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/oreeldadln/32/89185_2.png) [@oreeldadln](https://community.thunkable.com/u/oreeldadln)\
**Post date:** [June 8, 2020, 4:37pm UTC](https://community.thunkable.com/t/sum-list-from-local-db/602856/1 "2020-06-08T16:37:59Z")

</div>

Hello,

I’m looking for an option to get a number sum from a list located in the local DB Data sources.  
I managed to go around and create the desired sum number, but the problem is when I’m deleting a row from the data viewer the number goes crazy of course because the deleted item wasn’t deleted from the list properly.

In short, is there a smart way to create a sum number from a column in the local data sources DB and when an item is deleted, update the sum number correctly?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)\
**Post date:** [June 10, 2020, 12:26pm UTC](https://community.thunkable.com/t/sum-list-from-local-db/602856/2 "2020-06-10T12:26:39Z")

</div>

Hey @oreeldadln

There are a few examples of how to do this in the Community that you can find by searching for “[Sum List](http://community.thunkable.com/search?q=sum%20list)”

Here’s one that jumped out at me:

> [@How to sum numers from a list?](http://community.thunkable.com/t/how-to-sum-numers-from-a-list/111583/23):
>
> The “sum of list” block works like this. If the list contains only values ​​of the numeric type, then they will be summed up. If in the list there is at least one element of string type, then the operation of joining strings will be performed, as if all elements of the list are strings. To sum up the string values ​​of numbers, you need to use a loop through the list with the conversion of string type numbers to numbers.

let me know whether or not that works for you.

---

<div class="post-metadata">

**Author:** ![oreeldadln](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/oreeldadln/32/89185_2.png) [@oreeldadln](https://community.thunkable.com/u/oreeldadln)\
**Post date:** [June 13, 2020, 8:58pm UTC](https://community.thunkable.com/t/sum-list-from-local-db/602856/3 "2020-06-13T20:58:40Z")

</div>

Working Perfectly. Thank you!

---

<div class="post-metadata">

**Author:** ![jbexcellenceb5](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jbexcellenceb5](https://community.thunkable.com/u/jbexcellenceb5)\
**Post date:** [December 21, 2022, 11:06am UTC](https://community.thunkable.com/t/sum-list-from-local-db/602856/4 "2022-12-21T11:06:24Z")

</div>

I want to sum values in a database.  
Attach find my blocks. But it gives me a NaN answer. What am I doing wrong?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/7/b78c82a3e00dd90b59865ec992107d041b8c21ce.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 21, 2022, 4:32pm UTC](https://community.thunkable.com/t/sum-list-from-local-db/602856/5 "2022-12-21T16:32:48Z")

</div>

It looks like you’re trying to add the value of a single database cell to the total score three times.

If that’s not working, try (inside the repeat block) setting the value of a variable to the Get Value block first and then adding that variable to the total score. It could be that the repeat loop is happening too fast and the Get Value block doesn’t have time to complete. You might need to add a Wait 0 seconds block at the end of the repeat block or even Wait 0.03 seconds. See if either of those help.

---

<div class="post-metadata">

**Author:** ![jbexcellenceb5](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jbexcellenceb5](https://community.thunkable.com/u/jbexcellenceb5)\
**Post date:** [December 21, 2022, 7:14pm UTC](https://community.thunkable.com/t/sum-list-from-local-db/602856/6 "2022-12-21T19:14:53Z")

</div>

Thanks for the reply, but it is still not working.  
Any other easy ways to calculate the score in a database?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/a/3aa5560cfc8c944b46e93306e2adee25284458f3.png)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/0/20c9b0e5c6eb5e01dc62d50876796a1c5c258234.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 21, 2022, 7:19pm UTC](https://community.thunkable.com/t/sum-list-from-local-db/602856/7 "2022-12-21T19:19:44Z")

</div>

It could be that the Get Value block is still buggy. This has been a [long-standing issue](https://github.com/thunkable/thunkable-issues/issues/1138) and I’m not sure if it’s still causing problems. What happens if you set a label’s text to the Scores value in the loop and watch it? Do the values you’d expect to get from the Data Source appear?

You can also share a link to the project and I can test it myself which might help me find the cause faster.

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:25am UTC](https://community.thunkable.com/t/sum-list-from-local-db/602856/8 "2024-11-08T11:25:45Z")

</div>


