I'm doing a large set of nested IF/AND statements that isn't working correctly. It's supposed to check if both a user ID is the same as one in the cells 10 rows away, and if the sum of 10 cells in a column is equal to 10. If it is, it subtracts some timestamps. If it isn't, it's supposed to check the same things, but for 11 rows, then 12, 13,14 ect. I've gotten the formula to work with just 2 steps (checking 10 and 11 rows) as a test, but the large 10 step one doesn't work right. If the first condition is met, it's fine, but if it isn't, sometimes (but not always) it jumps to the final "false" result. It's probably a syntax error, but I've never done an IF statement this long. Anyone spot the mistake?
Column A is a user ID, B is a timestamp, and K gives me 1 if it is the first instance of an address, and 0 if it isn't. The idea is to see how long it takes for someone to go to 10 addresses.
The one that works:
=IF(AND(A39=A30,SUM(K30:K39)=10),B39-B30,IF(AND(A39=A29,SUM(K29:K39)=10),B39-B29,"unmeasured"))
The one that doesn't:
=IF(AND(A25=A16,SUM(K16:K25)=10),B25-B16,IF(AND(A25=A15,SUM(K15:K25)=10),B25-B15,IF(AND(A25-A14,SUM(K14:K25)=10),B25-B14,IF(AND(A25=A13,SUM(K13:K25)=10),B25-B13,IF(AND(A25=A12,SUM(K12:K25)=10),B25-B12,IF(AND(A25=A11,SUM(K11:K25)=10),B25-B11,IF(AND(A25=A10,SUM(K10:K25)=10),B25-B10,IF(AND(A25=A9,SUM(K9:K25)=10),B25-B9,IF(AND(A25=A8,SUM(K8:K25)=10),B25-B8,IF(AND(A25=A7,SUM(K7:K25)=10),B25-B7,"unmeasured"))))))))))
The same formula with line breaks for easy reading:
IF(AND(A25=A16,SUM(K16:K25)=10),B25-B16,
IF(AND(A25=A15,SUM(K15:K25)=10),B25-B15,
IF(AND(A25-A14,SUM(K14:K25)=10),B25-B14,
IF(AND(A25=A13,SUM(K13:K25)=10),B25-B13,
IF(AND(A25=A12,SUM(K12:K25)=10),B25-B12,
IF(AND(A25=A11,SUM(K11:K25)=10),B25-B11,
IF(AND(A25=A10,SUM(K10:K25)=10),B25-B10,
IF(AND(A25=A9,SUM(K9:K25)=10),B25-B9,
IF(AND(A25=A8,SUM(K8:K25)=10),B25-B8,
IF(AND(A25=A7,SUM(K7:K25)=10),B25-B7,"unmeasured"))))))))))
Column A is a user ID, B is a timestamp, and K gives me 1 if it is the first instance of an address, and 0 if it isn't. The idea is to see how long it takes for someone to go to 10 addresses.
The one that works:
=IF(AND(A39=A30,SUM(K30:K39)=10),B39-B30,IF(AND(A39=A29,SUM(K29:K39)=10),B39-B29,"unmeasured"))
The one that doesn't:
=IF(AND(A25=A16,SUM(K16:K25)=10),B25-B16,IF(AND(A25=A15,SUM(K15:K25)=10),B25-B15,IF(AND(A25-A14,SUM(K14:K25)=10),B25-B14,IF(AND(A25=A13,SUM(K13:K25)=10),B25-B13,IF(AND(A25=A12,SUM(K12:K25)=10),B25-B12,IF(AND(A25=A11,SUM(K11:K25)=10),B25-B11,IF(AND(A25=A10,SUM(K10:K25)=10),B25-B10,IF(AND(A25=A9,SUM(K9:K25)=10),B25-B9,IF(AND(A25=A8,SUM(K8:K25)=10),B25-B8,IF(AND(A25=A7,SUM(K7:K25)=10),B25-B7,"unmeasured"))))))))))
The same formula with line breaks for easy reading:
IF(AND(A25=A16,SUM(K16:K25)=10),B25-B16,
IF(AND(A25=A15,SUM(K15:K25)=10),B25-B15,
IF(AND(A25-A14,SUM(K14:K25)=10),B25-B14,
IF(AND(A25=A13,SUM(K13:K25)=10),B25-B13,
IF(AND(A25=A12,SUM(K12:K25)=10),B25-B12,
IF(AND(A25=A11,SUM(K11:K25)=10),B25-B11,
IF(AND(A25=A10,SUM(K10:K25)=10),B25-B10,
IF(AND(A25=A9,SUM(K9:K25)=10),B25-B9,
IF(AND(A25=A8,SUM(K8:K25)=10),B25-B8,
IF(AND(A25=A7,SUM(K7:K25)=10),B25-B7,"unmeasured"))))))))))