Link to home
Start Free TrialLog in
Avatar of lcor
lcor

asked on

EXCEL Running Sum Based on Column Values

I have 5 columns with possible values A, B, C, each will either add a point or subtract a point from a running sum based on value of the cell.  The 6th column will be the sum.

I need to come up with a yes or no signal in the 6th column  by adding a positive and negative points

Col1 = A
Col2 = B
Col3 = C
Col4 = A
Col5 = C

So if value = A, add a point
If value = B, subtract a point
If value = C, add a point

So if the sum is negative, the 6th cell will be red and if the sum is positive, the 6th cell will be green.
If color with this rule is too, difficult, replace with the letter N or Y.

Has anyone does this before?
Avatar of Fabrice Lambert
Fabrice Lambert
Flag of France image

This formula maybe:
=IF(OR(A1="A"; A1="C"); 1; -1) + IF(OR(B1="A"; B1="C"); 1; -1) + IF(OR(C1="A"; C1="C"); 1; -1) + IF(OR(D1="A"; D1="C"); 1; -1)

Open in new window

As for color, a simple conditional formatting will do the trick.
ASKER CERTIFIED SOLUTION
Avatar of Joe D
Joe D

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So if value = A, add a point
If value = B, subtract a point
If value = C, add a point
is that possible to have values other than A, B and C?
Avatar of Joe D
Joe D

Yes.  Substitute in the whatever values you want for A, B, and C.  

An alternate way to write the formula so you can change the values easily is to reference a cell that has the value you want to match rather than putting that value in the formula.  Here's the same formula, still in cell F5, rewritten this way, with A1=A, A2=B, and A3=C.  

=IF(COUNTIF(A5:E5,$A$1)-COUNTIF(A5:E5,$A$2)+COUNTIF(A5:E5,$A$3)>0,"Y","N")

Notice the $ signs in front of each part of the reference.  These will keep the reference as "absolute" when you copy the formula to other cells.  If you copy this formula to F6 notice what happens:

=IF(COUNTIF(A6:E6,$A$1)-COUNTIF(A6:E6,$A$2)+COUNTIF(A6:E6,$A$3)>0,"Y","N")

The references for the rows that you're evaluating will change (from row 5 to row 6), but the value you're evaluating against, A1, A2, and A3, didn't change.  This will make maintaining the spreadsheet easier if it grows over time.
Avatar of lcor

ASKER

I went to try the first solution in it's simplest form

=IF(OR(A1="A"; A1="C"); 1; -1)

but excel gives an error with the formula

what could be missing here?
Try changing the ";" to ","
upload your excel file here if necesary
Avatar of lcor

ASKER

I couldn't get the first solution to work with the second condition.

I'm investigated nested IF statements.

Here's a good website that explains them.

https://tinyurl.com/y8cp7955
Avatar of lcor

ASKER

This is the closest solution that I was able to get working.