PDA

View Full Version : Solved: If formula to match numbers +1 -3



Andrea C
03-10-2011, 01:53 PM
Hello Everyone,
I have tried to make this work with out luck :( . Any help is greatly appreciated. Here's what I am trying to accomplish:
Create groups of when the people ended at the same time, if they are under the same type (I think I have that part correct) - The problem is that when the ended (time) is +1, 2 or 3 minutes, it is still considered the same group as long as they are the same type. I don't know how to add to this the formula (for example if C2 = C1 or C2 is greater than C1 by 1, 2 or 3 minutes, and B2=B1, then give me D1, otherwise, give me D1+1) I have attached a small sample of data.. I am dealing with 600+ rows so fixing one by one is very time consuming and I don't really know how to work with the H:MM number type.
Please le tme know if I need to clarify this a bit more. Thank you for any help in advance, it is greatly appreciated.
Regards,
Andrea.

Bob Phillips
03-10-2011, 02:45 PM
Try

=IF(AND(B3=B2, (ABS(C3-C2)*24*60)<=3),D2,D2+1)

Aussiebear
03-10-2011, 03:20 PM
Does this formula need the space before the (ABS(.... section Bob?

Bob Phillips
03-10-2011, 03:29 PM
NO, I don't know why I added it, I am normally a stickler about removing spaces.

Aussiebear
03-10-2011, 03:39 PM
LOL, so I've noticed.

Andrea C
03-10-2011, 03:55 PM
Thank you very very much! It worked perfectly. I am a littl emebarrassed to ask, but would you mind explaining to me how the formula works? I would love to learn.
Thanks very much!

Bob Phillips
03-10-2011, 04:21 PM
In essence, I take the time away from the previous time, C3-C2, then take the absolute value of that, ABS(C3-C2), so as not to worry about negative numbers. I multiply that by 24 by 60 to turn it into decimal minutes, then chek it is less than or equal to 3.