Calculating sum/difference of two lists including empty lists

Hello,

I would like to calculate the differences between each value of two lists.
The first list is complete, but in the second list are empty lists.

When I want to take the sum or difference from these lists, it only calculates the values when there’s one available in both of them. I would like to get the difference between every value of these lists, so when there’s an empty list it needs to take the value of the other list as result.
image

Does someone know how to do this?
I found one article where they suggested to do this in python, but this is posted in 2018.
So I would like to know if there is another solution then using python because I’m not familiar with it.

Thanks!

I am not sure if i understand the question correctly but maybe you can replace an Empty List for 0.

NB
Post (an image of) your whole graph or the .dyn so people can help you better.

1 Like

I would first start by simplifying the list structure in Math.Sum as that’s going to give you some additional trouble as well. Then it should just be an issue of converting empty lists to nulls. You could also add a 0 to all sublists before calculating the sum, since that won’t affect values but will ensure that all lists have at least one number to calculate with.

1 Like

Hello @bvs1982, @Nick_Boyts

symplifying the list structure before sum the list was really helpfull!
Afterwards I replaced the nulls with zero’s, but using Math.Sum didn"t help.

Instead, I used Mass Addition, is it okay to use this node to fix it?

Thank you very much for your help!

You replaced the nulls with a string, not a number. You need to use a number in order for the sum to calc.

2 Likes

Thank you!