Positive/Negative Columns part II

codeman_not

New Member
Joined
Jun 25, 2011
Messages
8
Ok, I will try to explain this better. I have four columns (A1:D1). Those columns will either have a "1" or "-1" in them. In column 5, I am trying to figure out a way to show me how many of the columns are postive or negative (or the net positve vs negative of the four columns) (IE: 1,1,1,1 - column 5 = 4 and -1,-1,-1,-1 - column 5 = -4 and finally 1,1,-1,-1 = 0). I tried just using SUM(A1:D1), and that works for all scenarios except when there are 3 positves or negatives. IE: 1,1,1,-1 returns 2, when I am looking for it to return 3 (for 3 net positive columns). The same thing for the inverse (-1,-1,-1,1 = -2). Anyone know of any other way to tackle this other than SUM?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Here is a complete example of what I am trying to do:

1,1,1,1 (@sum = 4), (desired = 4)
1,1,1,-1 (@sum = 2), (desired = 3)
1,1,-1,-1 (@sum = 0), (desired = 0)
-1,-1,1,1 (@sum = 0), (desired = 0)
-1,-1,-1,1 (@sum = -2),(desired = -3)
-1,-1,-1,-1, (@sum= -4), (desired = -4)
 
Upvote 0
Assuming that your data is in columns A to D is this what you are looking for:

=IF(COUNTIF(A2:D2,1)>2,COUNTIF(A2:D2,1),IF(COUNTIF(A2:D2,-1)>2,-COUNTIF(A2:D2,-1),0))

Kelbo
 
Upvote 0
I still don't understand why -1, -1, 1, 1 is counted as 0 and -1, -1, -1, 1 is counted as -3.

One is comparing positive agianst negative, the other is counting only the negative.
 
Upvote 0
Hi Mike. In regards to your question (why is 1,1,-1,-1 = 0), let me explain it this way - Let's say 1 or -1 represents a sales increase or decrease for a company over the last 4 quarters. I am trying to determine how many of those quarters were positive or negative. In the case of 1,1,1,-1 - three of the four quarters were positive - so thats what I want to show. With respect to "1,1,-1,-1", there were two positive and two negative quarters - the two offset each other and the net effect is a wash or 0. Hope that explains where I am coming. Thanks again for your help!
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,144
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top