# Sum Nested Lists Values

**URL:** <https://forum.dynamobim.com/t/sum-nested-lists-values/97510>\
**Category:** Lists-Logic\
**Created:** [January 25, 2024, 7:48pm UTC](https://forum.dynamobim.com/t/sum-nested-lists-values/97510 "2024-01-25T19:48:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![claracoutoCD8EP](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@claracoutoCD8EP](https://forum.dynamobim.com/u/claracoutoCD8EP)\
**Post date:** [January 25, 2024, 7:48pm UTC](https://forum.dynamobim.com/t/sum-nested-lists-values/97510/1 "2024-01-25T19:48:43Z")

</div>

Hi there,

I have a list, and I want to sum the values of the nested lists into a new list. However, Neither `math.sum` nor `List.Reduce` is working for me.

I have a varying number of Level @3 lists inside Level @4 lists

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/a/ba318df78ffc00a7808bf8cd68ea6763f16a56fa.png)

So, I just want to sum all P1’s/P2’s/P3’s and P4’s.

I have tried to flatten the original one, but then it came out with null values. Then, using the ‘List.ReplaceNull’ node, the null values were replaced with zeros. However, I’ve now lost the original list in which my values were grouped by a certain parameter.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [January 25, 2024, 8:03pm UTC](https://forum.dynamobim.com/t/sum-nested-lists-values/97510/2 "2024-01-25T20:03:33Z")

</div>

Sum requires a list so you’ll have to flatten at the appropriate depth as you guessed, but you won’t be able to sum mixed values (numbers and strings). You need to clean out all the strings first.

---

<div class="post-metadata">

**Author:** ![claracoutoCD8EP](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@claracoutoCD8EP](https://forum.dynamobim.com/u/claracoutoCD8EP)\
**Post date:** [January 26, 2024, 10:07am UTC](https://forum.dynamobim.com/t/sum-nested-lists-values/97510/3 "2024-01-26T10:07:06Z")

</div>

I Will try that, thank you very much.
