lundi 4 mai 2015

closest value multiple criteria excel

I'm trying to find a number closest to 100 in Column Sheet1!$J$2:$J$131106

1st IF) But only in the rows where a certain date (Sheet2!W16) matches in column Sheet1!$C$2:$C$131106

(2nd IF) and for rows where another certain date (Sheet2!$F$18) matches in column Sheet1!$F$2:$F$131106

(3rd IF) and for rows where a specific letter - either P/C ($G21) matches in column Sheet1!$H$2:$H$131106

With this formula =INDEX(Sheet1!$J$2:$J$131106;MATCH(MIN(IF((Sheet1!$C$2:$C$131106=Sheet2!W16)*(Sheet1!$F$2:$F$131106=Sheet2!$F$18)*(Sheet1!$H$2:$H$131106=$G21);ABS(Sheet1!$J$2:$J$131106-Sheet2!$B$12)));IF((Sheet1!$C$2:$C$131106=Sheet2!W16)*(Sheet1!$F$2:$F$131106=Sheet2!$F$18)*(Sheet1!$H$2:$H$131106=$G21);ABS(Sheet1!$J$2:$J$131106-Sheet2!$B$12));0))

I have no idea why, but my formula ignores the 2nd if and just takes whatever date it wants from that column but follow through with the two other IFs. It find a number closest to 100 in a row that has these 3 values 09-01-2009, 17-01-2009 and C. The 2nd criteria says the date has to be 21-02-2009 - why does it take 17-01-2009 instead?

Sample of data if needed - it is in cell Z16 on sheet2

Aucun commentaire:

Enregistrer un commentaire