Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to create a formula (although I think it will need to be a macro). The table has 2 columns, column one has percentages. What needs to happen is whichever 3 rows have the lowest percentage column 2 needs to be changed to -3,-2 and -1. If a percentage is over 3% then make column 2 be 1. I have the over 3% working but not the bottom 3 percentages. Anyone point me in the right direction? Thanks!

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

For values in A in the percentage format:

=IF(COUNT(A:A)-COUNTIF(A:A,">"&A1)<= 3,
    COUNT(A:A)-COUNTIF(A:A,">"&A1)-4,IF(A1>0.3,1,0))
share|improve this answer
    
Thanks, I actually just found out the same thing, I was trying to use nested If's with VB syntax. –  wolfvilleian Dec 7 '10 at 3:43
add comment

Since you've only got three levels to compare (min,max and middle), I think this can be accomplished with a nested if statements.

The rules I got from the above are: there three options: min which should be -1, max which should be -3 and middle which should be -2, unless the value is over 3%, then the value should be 1.

=if(a1 = min(A1:A3);(if (a1 > 3% ; 1; -1));if (a1 = max(A1:A3); (if(a1 > 3%; 1; -3));if(a1 > 3%; 1; -2))

The first if check for a min value, and then checks for the magic value of 3%. The else checks for the max value, then checks for the magic value. If it makes it to the second else, then its got to be the middle value. Compare it to the magic value of 3% and your done.

share|improve this answer
    
My final formula came out to be: =IF(B20=SMALL(B7:B21,1),-3, IF( B20=SMALL(B7:B21,2),-2, IF( B20=SMALL(B7:B21,2),-2, IF(B20=LARGE(B7:B21,1),3,IF(B20=LARGE(B7:B21,2),2,IF(B20=LARGE(B7:B21,3),1,IF(B2‌​0>=0.03,1,))))))) –  wolfvilleian Dec 7 '10 at 3:44
    
Sorry, found an error in my own, fixed: =IF(B12=SMALL(B7:B21,1),-3, IF( B12=SMALL(B7:B21,2),-2, IF( B12=SMALL(B7:B21,3),-1,IF(B12>0, IF(B12=LARGE(B7:B21,1),3,IF(B12=LARGE(B7:B21,2),2,IF(B12=LARGE(B7:B21,3),1,IF(B1‌​2>=0.03,1,)))),0)))) There's a IF in there that wasn't originally mentioned in the question –  wolfvilleian Dec 7 '10 at 4:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.