Ex.1
13 15 17 answer is 15
Ex.2
12 16 13 answer is 13
Ex.3
11 11 15 answer is 11
if 2 nos are equal the answer is the 2 equal,
if all nos are different the answer is middle
how to do this? also in excel
tnx
Printable View
Ex.1
13 15 17 answer is 15
Ex.2
12 16 13 answer is 13
Ex.3
11 11 15 answer is 11
if 2 nos are equal the answer is the 2 equal,
if all nos are different the answer is middle
how to do this? also in excel
tnx
Put the first number in A1, the second in B1 and the third in C1, then use this to get the answer:
Code:=IF(A1=B1,A1,IF(A1=C1,A1,B1))
Example number 2 seems to have the wrong answer, as all three numbers are different, so the answer should be the middle number, which is 16.
I think the means the middle as in their size, not placement in the list. 16 > 13 and 13 > 12 so 13 is the 'middle' number. Isn't that called the median..?
Ok, I misinterpreted what was stated, but that makes more sense.
Actually, it IS the median, and for the case where more than one number is the same, you are getting the mode. Since both of those are built-in functions in Excel, that suggests an inferior solution. Mode returns NA for cases where all are different, so If not mode, get median. I doubt that could be written simply, though, but I have no recent experience with Excel.
tnx to all here is the final solution:
=IF(A1=B1,A1,IF(A1=C1,A1,MEDIAN(A1:C1)))