PDA

Click to See Complete Forum and Search --> : could you answer?


basti42
Jun 22nd, 2009, 04:40 AM
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

03myersd
Jun 22nd, 2009, 10:13 AM
Put the first number in A1, the second in B1 and the third in C1, then use this to get the answer:

=IF(A1=B1,A1,IF(A1=C1,A1,B1))

Shaggy Hiker
Jun 22nd, 2009, 11:45 AM
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.

NickThissen
Jun 22nd, 2009, 11:48 AM
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..?

Shaggy Hiker
Jun 22nd, 2009, 11:55 AM
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.

basti42
Jun 22nd, 2009, 11:05 PM
tnx to all here is the final solution:

=IF(A1=B1,A1,IF(A1=C1,A1,MEDIAN(A1:C1)))