max value

A

aaaist

hi
i need help lol
for exemple:

A B
1 joao 5.5
2 fred 8.6
3 Jose 7.8

i want the excel calc the maximum value and return me the name of who had
the max value.!! it´s posible??

tks
 
D

DOR

Try

=INDEX(A:A,MATCH(MAX(B:B),B:B,0))

Note, however, that it will return the first person (from the top) who
has the maximum value.
 
H

Harlan Grove

DOR said:
Try

=INDEX(A:A,MATCH(MAX(B:B),B:B,0))

Note, however, that it will return the first person (from the top) who
has the maximum value.

And if the last/bottommost person is equally acceptable,

=LOOKUP(2,1/(B1:B100=MAX(B1:B100)),A1:A100)

Also, using entire column references can cause probems if the table to be
searched spans a few hundred rows or less and values or formulas are
inadvertently placed well below the table.
 
D

DOR

Good point, Harlan, about the danger of entire column references.
However, if you follow the practice of using one sheet per table or
data entitiy, in data modeling terms, and using entire column
references, as I like to where possible, you avoid the potential errors
resulting from inadvertent additions below the table range. I guess
you swap one set of frustrations for another.
 
A

aaaist

hi
i put it in a cell and a had this error "err:501"
can you write the expression i have to put for the exemple?
if it result in the exemple i have my problem solve:D
tks
"DOR" escreveu:
 
D

DOR

=INDEX(A1:A3,MATCH(MAX(B1:B3),B1:B3,0))

or, using LOOKUP,

=LOOKUP(MAX(B1:B3),B1:B3,A1:A3)

These will get the first instance of the maximum value.
 
H

Harlan Grove

DOR wrote...
....
=LOOKUP(MAX(B1:B3),B1:B3,A1:A3)

These will get the first instance of the maximum value.

LOOKUP may return the correct result for 3 row ranges, but your formula
isn't a general solution. If A1:B4 contained

a 58
b 8
c 53
d 50

the formula

=LOOKUP(MAX(B1:B4),B1:B4,A1:A4)

happily returns d rather than a.

Want to try to explain that?
 
A

Aladin Akyurek

What about having "aaaist" with 8.6 as the associated value? Are you
going to ignore "aaist" or one of the pair <fred, aaist>? If not:

Try my post in:

http://tinyurl.com/562xz

or construct a pivot table, which can be made show the Top 1 values.
hi
i need help lol
for exemple:

A B
1 joao 5.5
2 fred 8.6
3 Jose 7.8

i want the excel calc the maximum value and return me the name of who had
the max value.!! it´s posible??

tks

--

[1] The SumProduct function should implicitly coerce the truth values to
their Excel numeric equivalents.
[2] The lookup functions should have an optional argument for the return
value, defaulting to #N/A in its absence.
 
B

Bruno Campanini

Harlan Grove said:
DOR wrote...
...

LOOKUP may return the correct result for 3 row ranges, but your formula
isn't a general solution. If A1:B4 contained

Not exactly.
The LOOKUP returns the correct result if the cell to
be returned is not the first one in the range.
Unexplainable!

I resembles VBA FIND behaviour which is unable to find
at the first stroke the occurrence located at the first place
in search range.

Bruno
 
H

Harlan Grove

Bruno Campanini wrote...
....
Not exactly.
The LOOKUP returns the correct result if the cell to
be returned is not the first one in the range.
Unexplainable!

Not unexplainable. My question was purely rhetorical. LOOKUP *always*
assumes the lookup range/array is sorted in ascending order. It almost
certainly uses a binary search algorithm. The incorrect result from the
example I provided is just one of possibly many unsorted lookup ranges
that would cause the binary search to fail and LOOKUP to return an
incorrect result.
I resembles VBA FIND behaviour which is unable to find
at the first stroke the occurrence located at the first place
in search range.

Not the same. The .Find method of the Excel Range class doesn't find
matches in the first cell of the range first when there are such
matches because it was apparently programmed to search in the next cell
first. It's the same functionality as provided by the Edit > Find menu
command, and that also skips the active cell when finding the first
match in a range, presumably on the assumption that the user should
have been able to see that there's a match in the active cell without
having to run Edit > Find.
 
D

DOR

Which is why I always use INDEX(....,MATCH(....)) rather than any of
those fragile *LOOKUP formulas ...

Silly of me to mention LOOKUP here ...
 
B

Bruno Campanini

Not the same. The .Find method of the Excel Range class doesn't find
matches in the first cell of the range first when there are such
matches because it was apparently programmed to search in the next cell
first. It's the same functionality as provided by the Edit > Find menu
command, and that also skips the active cell when finding the first
match in a range, presumably on the assumption that the user should
have been able to see that there's a match in the active cell without
having to run Edit > Find.

Mmm...
Are you saying it's acting wrong because it was programmed to
do wrong?
Is it a justification?

Regards
Bruno
 
H

Harlan Grove

Bruno Campanini said:
Mmm...
Are you saying it's acting wrong because it was programmed to
do wrong?
Is it a justification?

It's not acting 'wrong'. I'm speculating, but it seems reasonable to me for
the interactive Edit > Find command to skip the active cell initially
because it should be obvious whether or not there's a match in it without
running the command. The only arguable design mistake would be making the
..Find method of the range class work the same way, but it's obvious to me
why Microsoft chose to use the existing Edit > Find code for the Range
class's .Find method and also that it would function EXACTLY the same as the
menu command.
 
H

Harlan Grove

DOR said:
Which is why I always use INDEX(....,MATCH(....)) rather than any of
those fragile *LOOKUP formulas ...

Silly of me to mention LOOKUP here ...

Very silly since you seem to have ignored my LOOKUP formula,

=LOOKUP(2,1/(B1:B100=MAX(B1:B100)),A1:A100)

which always and dependably returns the cell in A1:A100 corresponding to the
LAST MAX value in B1:B100. Fragile it isn't, though obscure it may be. As
for VLOOKUP, it's not as flexible as INDEX(..,MATCH(..)), but if searching
in the first column of a table it's obviously much more efficient (one
function call better than two).
 
B

Bruno Campanini

Harlan Grove said:
It's not acting 'wrong'. I'm speculating, but it seems reasonable to me
for the interactive Edit > Find command to skip the active cell initially
because it should be obvious whether or not there's a match in it without
running the command. The only arguable design mistake would be making the
.Find method of the range class work the same way, but it's obvious to me
why Microsoft chose to use the existing Edit > Find code for the Range
class's .Find method and also that it would function EXACTLY the same as
the menu command.

Ciao Harlan,
My opinion diverges substantially from yours as for class's
..Find method.
But I respect your opinion.

Bruno
 
D

DOR

Agreed on virtually all counts. Mea culpa, mea culpa, mea maxima culpa!
And thank you for posting such an elegant and dependable formula (my
comment re fragility really applied to the H and VLOOKUPs, not to
LOOKUP, since it does not use the column index number, which is usually
given in VLOOKUP examples as an actual number as opposed to a variable
expression) - I'm afraid I responded in haste when I should have taken
more time, and I should certainly have confined my response to the
functions I use and know. I am lashing myself with the proverbial wet
noodles, and have definitely learned something from you (and from
Aladin's post below), both technically and otherwise.

Maybe I can learn some more vis-a-vis the merits/demerits of VLOOKUP,
since we may differ somewhat on its merits. It appears to me that
VLOOKUP can be more efficient and useful than INDEX/MATCH when:

(1) you are certain that neither you nor anyone else will ever move the
target column to the left of the search column (e.g. the search column
will ALWAYS be the first column of the table or list, as you suggest),
and

(2) you use an expression such as

COLUMN(Target)-COLUMN(Search)+1

for the column index number, to make it adapt to column insertions
between the search and target column, (which is how many people seem to
expand a table to accommodate more columnar values), and

(3) you are extracting target values from no more than two or three
columns in the table for each criterion value, as opposed to extracting
many values from different target columns for each criterion or search
argument value, all of which can be extracted using one MATCH function
on the search argument, plus one INDEX function per value extracted.
In all likelihood, a MATCH and a VLOOKUP with similar parameters are
similar in time cost, with a VLOOKUP being slightly more expensive
because it must also index into the target column, but it should do so
less expensively than the INDEX function. However the INDEX function
itself should be significantly less expensive than a VLOOKUP since it
does not need to search. Therefore, for a given table depth, there
should be a crossover in efficiency at some number of values retrieved
per criterion (3,4,?), when, for n values retrieved, the cost for n
VLOOKUPs becomes greater than the cost for one MATCH plus n INDEXes. If
you test for absence of the search criterion, the time benefits of
INDEX/MATCH could be greater, depending on how you test. (I wonder if
anyone has benchmarked these two approaches?)

If any of 1, 2, or 3 are untrue, it appears to me that you are probably
better off using INDEX and MATCH, either in one formula or separately,
as appropriate, even though you may trade some efficiency for
maintainability.

You are clearly more knowlegeable on XL than I, and I would be happy to
know if and where my thinking is awry on this issue.
 
Top