Comparing 3 numbers

G

goldcomac

I'm comparing prices at Baker's, Walmart, and Costco. I've got the
item, unit cost, size, and cost per ounce. I know how to make
comparisons between two numbers using a statement such as:

=IF(D3>I3,"Bakers","Walmart")

but how do I add Costco to the equation?

Thank you.
 
M

Marcelo

--
regards from Brazil
Thanks in advance for your feedback.
Marcelo

you should use if(and or if(or

hth

"(e-mail address removed)" escreveu:
 
J

JLatham

Try a variation of this:
=IF(AND(A2<B2,A2<C2),"Bakers",IF(AND(B2<A2,B2<C2),"Costco","Walmart"))

change references to A2 to the column with Bakers costs in it,
change references to B2 to column with Costco prices, and
change references to C2 to column with Walmart prices.

I believe that'll do the trick for you. Now if all prices are equal - you
will get sent to Walmart - so you might want to rearrange things so that the
closest outlet ends up being the "default when all prices are equal" :).
 
G

goldcomac

Looking in the help index search box for MIN or MAX should help.

This only returns a number, correct? In other words, =MIN(D3,I3,N3)
will only give a number, not a store name. I'd like to be able to see
the name of the store with the lowest prices.
 
J

JLatham

Actually, the previous formula doesn't always return the proper value (I hate
it when that happens!). But this one would do it for certain - assumes the
missing item is in column O (D = walmart prices, I = baker's and O =
costco's) You can change them around as desired. In the case of 2, or 3,
prices being the same, it will return the first one it encounters.

=IF(MIN(D2,I2,O2)=D2,"Walmart",IF(MIN(D2,I2,O2)=I2,"Bakers","Costco"))
 
R

Roger Govier

Hi

Supposing your store names are in A1:C1 and the values you are comparing are
in A2:C2

=INDEX($A$1:$C$1,MATCH(MIN($A2:$C2),$A2:$C2,0))
 
D

Don Guillett

This should do it.
=INDEX($1:$1,MATCH(MIN(A2:C2),2:2,0))

a b c d
2 1 4 b
2 4 5 a
5 3 2 c
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
Looking in the help index search box for MIN or MAX should help.

This only returns a number, correct? In other words, =MIN(D3,I3,N3)
will only give a number, not a store name. I'd like to be able to see
the name of the store with the lowest prices.
 
D

David Biddulph

If you are looking for the maximum, use
=IF(MAX(D3,I3,X3)=D3,"Bakers",IF(MAX(D3,I3,X3)=I3,"Walmart","Costco"))
If you are looking for the minimum, adjust the formula as necessary.
 
G

goldcomac

Try a variation of this:
=IF(AND(A2<B2,A2<C2),"Bakers",IF(AND(B2<A2,B2<C2),"Costco","Walmart"))

change references to A2 to the column with Bakers costs in it,
change references to B2 to column with Costco prices, and
change references to C2 to column with Walmart prices.

I believe that'll do the trick for you.  Now if all prices are equal - you
will get sent to Walmart - so you might want to rearrange things so that the
closest outlet ends up being the "default when all prices are equal" :).

Can you help me read this in English?

=IF(AND(D3<I3,D3<N3),"Walmart",IF(AND
(I3<D3,I3<N3),"Costco","Walmart"))

If D3 is less than I3, and D3 is less than N3, then the answer is
Walmart, but if I3 is less than D3, and I3 is less than N3, then
Costco. But if neither of those two true, then the answer is Walmart.
Is that correct?
 
J

JLatham

You translated it properly - and it works well with 3 unique values, but when
you have 2 that are the same, it can fail. See my other post (and also the
post by David Biddulph) for a method that works correctly in all cases.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top