I want a column where it only sums the values of a different column that match a string in a third column. I'll explain with an example. I have the following:
Col(A) Col(B) Col(C) Col(D)
Buy 500 500 80
Buy 500 1000 80
Exchange 1000 2000 80
Dividend 80 2080 80
Buy 500 2580 80
Exchange 0 2580 80
Dividend 100 2680 80
Dividend 300 2980 80
Buy 500 3480 80
Exchange 1500 4980 80
Dividend 30 5010 80
In Col(C), I have used Set Values to sum the values in column B: Col(C) = Sum(Col(B)). No problem there. What I want to do in Col(D) is to sum only the values listed as "Dividend".
Before I even try a sum, I thought I'd try to see if I can easily pick out the values labeled as "Dividend", so I used lookup in this fashion in Set Values:
Col(D) = lookup("Dividend",Col(A),Col(B))
However, doing this fills the entire Col(D) with only the first "Dividend" value. So Col(D) now looks like the example above. What went wrong? I assumed it would pick out the "Dividend" value in each row and (maybe) fill the rest with zeros. Something like this (note, before I'm trying a sum):
Col(A) Col(B) Col(C) Col(D)
Buy 500 500 0
Buy 500 1000 0
Exchange 1000 2000 0
Dividend 80 2080 80
Buy 500 2580 0
Exchange 0 2580 0
Dividend 100 2680 100
Dividend 300 2980 300
Buy 500 3480 0
Exchange 1500 4980 0
Dividend 30 5010 30
Any help? Or a better idea?