# \[Solved\] Calculate the average from the list

**URL:** https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882
**Category:** Questions about Thunkable X
**Tags:** solved
**Created:** [December 22, 2021, 9:47pm UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882 "2021-12-22T21:47:51Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![stronazyskuup](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@stronazyskuup](https://community.thunkable.com/u/stronazyskuup)
#### Post date: [December 22, 2021, 9:47pm UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882/1 "2021-12-22T21:47:52Z")

</div>

I need to calculate the average from this list. everything works, but the variable is overwriting and I have to turn the applications off and on for the calculations to be correct. What can I do with this?

 ![20211222_223611](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/2/b21d9d3d866047135af5addcc206e0ef7746d4a7.jpeg)

---

<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 22, 2021, 10:31pm UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882/2 "2021-12-22T22:31:48Z")

</div>

We can’t help you without seeing a screenshot of your blocks or a link to your project.

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [December 22, 2021, 11:01pm UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882/3 "2021-12-22T23:01:24Z")

</div>

Check out this recent post from Thunker @David_Wolber

> [@Adding up numbers](https://community.thunkable.com/t/adding-up-numbers/1658861):
>
> [Video Tutorial](https://draganddropcode.com/add-the-numbers-in-a-spreadsheet/) showing how to add up numbers in a spreadsheet, e.g., compute an average rating. Learn basics of repeat blocks, if blocks, and how apps add. The app uses drag and drop interface

---

<div class="post-metadata">

### Author: ![stronazyskuup](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@stronazyskuup](https://community.thunkable.com/u/stronazyskuup)
#### Post date: [December 22, 2021, 11:21pm UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882/4 "2021-12-22T23:21:31Z")

</div>

Aha… sorry 😉

---

<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 23, 2021, 2:06am UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882/5 "2021-12-23T02:06:47Z")

</div>

Okay, well that function will add each list item to create a **sum** , not an average. If you want an average, then you need to do `set app variable total to app variable total + j` (or just `change app variable total by j`, which does the same thing) and then below the loop, `set app variable average to app variable total/length [list of values in payments history in Table 1 in price]`.

If you have the data in Google Sheets or Airtable already, you can just use a formula to get the average. But if the data is in a local data source, you’ll need a function like you’re using.

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [December 23, 2021, 2:15am UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882/6 "2021-12-23T02:15:46Z")

</div>

You can average a list. Would this help?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/1/c18fc6f35843dba6ccf48b31d4d9d880d0d1a3d1.jpeg)

---

<div class="post-metadata">

### Author: ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)
#### Post date: [December 23, 2021, 9:09am UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882/7 "2021-12-23T09:09:30Z")

</div>

after all these years, i never noticed that you could do sum, average, etc and other list-related functions with ready-made blocks!!! i always had to write a sum function everytime i needed one! (i was looking for sum in the math blocks but there was none)

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

---

<div class="post-metadata">

### Author: ![stronazyskuup](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@stronazyskuup](https://community.thunkable.com/u/stronazyskuup)
#### Post date: [December 23, 2021, 9:34am UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882/8 "2021-12-23T09:34:57Z")

</div>

below I have unpinned blocks that define the length of the list and divide the sum by these blocks. my blocks calculate the mean but overlap in the variable. I have to turn off and turn on the Application for the result to be correct. every time i use the “average” function everything is x2 and so every time the function restarts. only resetting the app helps. I don’t know how to stop it.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [December 23, 2021, 10:56am UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882/9 "2021-12-23T10:56:15Z")

</div>

> [@manyone](#):
>
> i never noticed that you could do sum, average, etc

Sometimes it is a good idea to have your own functions.  
Try the `sum` or `average` on the block like this  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/2/1254a692e8a80c825ab5c89f21cc8e7b0b5b0b4e.png)  
You will see that it does not work and you will revert to building your own function. Lists generated from `Data Sources` default to **text** and therefore the calculation functions do not work with them.

---

<div class="post-metadata">

### Author: ![stronazyskuup](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@stronazyskuup](https://community.thunkable.com/u/stronazyskuup)
#### Post date: [December 23, 2021, 11:42am UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882/10 "2021-12-23T11:42:55Z")

</div>

here all the blocks. the function works, but the computations overlap each time I want to use it. If that’s not possible, how else can I build such a function?

 ![20211223_123859](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/9/49cd9d2e6267063b55c20f1755ed1752a52e49b9.jpeg)

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [December 23, 2021, 2:07pm UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882/11 "2021-12-23T14:07:10Z")

</div>

Inside your `average` function, the first block should be `set app variable average to 0`. This will ensure that the average is not being added up every time.

---

<div class="post-metadata">

### Author: ![stronazyskuup](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@stronazyskuup](https://community.thunkable.com/u/stronazyskuup)
#### Post date: [December 23, 2021, 3:42pm UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882/12 "2021-12-23T15:42:15Z")

</div>

Omg… THX

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)
#### Post date: [March 23, 2022, 3:43pm UTC](https://community.thunkable.com/t/solved-calculate-the-average-from-the-list/1658882/13 "2022-03-23T15:43:09Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
