# Math.sum on list

**URL:** <https://forum.dynamobim.com/t/math-sum-on-list/53695>\
**Category:** DesignScript\
**Created:** [August 4, 2020, 6:58am UTC](https://forum.dynamobim.com/t/math-sum-on-list/53695 "2020-08-04T06:58:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![shershahbacha9](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@shershahbacha9](https://forum.dynamobim.com/u/shershahbacha9)\
**Post date:** [August 4, 2020, 6:58am UTC](https://forum.dynamobim.com/t/math-sum-on-list/53695/1 "2020-08-04T06:58:05Z")

</div>

Hello,  
I have a list and wanna do Math.sum within sublists of list. I tried with @list but still not working. As in picture attached, I want sum of numbers under marked 0 List, 1 List and so on. I dont know how should i remove the extra lists under these main lists i.e these four lists under marked 0 List and son on. Because when i use List.flatten , it removes lists from other end ![h3](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/a/5ad6013af37eed9bdff4216b57aa108ec9a74e58.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [August 4, 2020, 7:20am UTC](https://forum.dynamobim.com/t/math-sum-on-list/53695/2 "2020-08-04T07:20:57Z")

</div>

Try List.Flatten but @L3 (or 2 - I get this one wrong often enough).

---

<div class="post-metadata">

**Author:** ![shershahbacha9](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@shershahbacha9](https://forum.dynamobim.com/u/shershahbacha9)\
**Post date:** [August 4, 2020, 7:23am UTC](https://forum.dynamobim.com/t/math-sum-on-list/53695/3 "2020-08-04T07:23:51Z")

</div>

it do not sum the number at @L3 also and also chnage the structure of list. ![h4](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/b/db9c622feb64244fb9d9f7e5a700023e16bcde8f.png)

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [August 4, 2020, 7:38am UTC](https://forum.dynamobim.com/t/math-sum-on-list/53695/4 "2020-08-04T07:38:29Z")

</div>

@shershahbacha9 First I’d advice trying to simplify the list structure, if possible.  
If not possible, you could try something like this …

 ![sum](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/a/ca144eca85d58a96918d6405b6195f98f7578072.png)

---

<div class="post-metadata">

**Author:** ![shershahbacha9](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@shershahbacha9](https://forum.dynamobim.com/u/shershahbacha9)\
**Post date:** [August 4, 2020, 7:56am UTC](https://forum.dynamobim.com/t/math-sum-on-list/53695/5 "2020-08-04T07:56:08Z")

</div>

@Vikram_Subbaiah I dont wanna change the list structure as i need it in the end. Its areas for each level and these empty lists should also go on so at the end shows that at this level we dont have any building mass. For this reason, i was trying to replace empty lists to a string but still trying due to complex list structure. Now i tried your this suggestion but it changes the list structure and empty lists are also removed which i dont want.

 ![h6](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/1/41e4527b8d450cd7041f86198f2853a517bde397.png)

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [August 4, 2020, 8:28am UTC](https://forum.dynamobim.com/t/math-sum-on-list/53695/6 "2020-08-04T08:28:50Z")

</div>

> [@shershahbacha9](#):
>
> I dont wanna change the list structure as i need it in the end.

The input nodes are blue in my example because I’ve checked _Keep List Structure_  
Doing the same on the _Math.Sum_ node might get you the intended result.  
You’ll need to handle the _nulls_ though

 ![sum1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/1/81b10ec1eb525a9930956d6f9580d90c3c035844.png)

---

<div class="post-metadata">

**Author:** ![shershahbacha9](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@shershahbacha9](https://forum.dynamobim.com/u/shershahbacha9)\
**Post date:** [August 4, 2020, 8:38am UTC](https://forum.dynamobim.com/t/math-sum-on-list/53695/7 "2020-08-04T08:38:01Z")

</div>

I used Math.Sum two times and it gave me what I wanted. Is It a right way ?

 ![h9](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/7/d7da23504f561d7ee5229cd9962ebf0b37c9a77c.png)

---

<div class="post-metadata">

**Author:** ![shershahbacha9](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@shershahbacha9](https://forum.dynamobim.com/u/shershahbacha9)\
**Post date:** [August 4, 2020, 8:42am UTC](https://forum.dynamobim.com/t/math-sum-on-list/53695/8 "2020-08-04T08:42:28Z")

</div>

Thanks alot @Vikram_Subbaiah. I did what you suggested and it worked as seem in the SS attached. The problem is im using Revit in German and sometimes cant get what the nodes are saying but this thing could help me in my other problems too. Thanks

 ![h10](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/0/b090599048daa0be3d185d8799985307e38a8377.png)
