Hi,
I have a series of variables which can contain both positive and negative numbers. Is there any way, or function, that I can use to sum only the positive numbers. And then, to create another formula to sum only the negative numbers.
So basically from the list of variables I will be summing all positive numbers in one calculation and then in a separate calculation, I will sum all of the negative numbers?
I don't see a function that allows for this type of math?
Sum only positive numbers from a list of variables [SOLVED]
-
- Posts: 50
- Joined: 28 Sep 2014
- Has thanked: 7 times
- TJ
- Posts: 7742
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Sum only positive numbers from a list of variables
1. add up all the numbers and save the result as var1
2. add up all the numbers in absolute value (ie change all the neg to pos) and save the result as var2
3. (var1 + var2)/2 = sum of all the positive numbers
4. (var1 - var2)/2 = sum of all the negative numbers
2. add up all the numbers in absolute value (ie change all the neg to pos) and save the result as var2
3. (var1 + var2)/2 = sum of all the positive numbers
4. (var1 - var2)/2 = sum of all the negative numbers
- TJ
- Posts: 7742
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Sum only positive numbers from a list of variables
or you can make a loop to go over the numbers one by one.
if the number is positive, then sum it to var1,
if the number is negative, then sum it to var2.
if the number is positive, then sum it to var1,
if the number is negative, then sum it to var2.
-
- Posts: 50
- Joined: 28 Sep 2014
- Has thanked: 7 times
Re: Sum only positive numbers from a list of variables [SOLVED]
Thanks TJ - what an interesting way of coming up with the solution. I am working with all variables and will be summing them. I am not so familiar with loops so I will try the solution involving the absolute value first. Thanks again!