Results 1 to 6 of 6

Thread: could you answer?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    could you answer?

    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
    *****************
    VB6,PHP,VS 2005

  2. #2
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: could you answer?

    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))

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: could you answer?

    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.
    My usual boring signature: Nothing

  4. #4

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: could you answer?

    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.
    My usual boring signature: Nothing

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    Re: could you answer?

    tnx to all here is the final solution:

    =IF(A1=B1,A1,IF(A1=C1,A1,MEDIAN(A1:C1)))
    *****************
    VB6,PHP,VS 2005

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width