Row with highest value

ngocpdn

New Member
Joined
Jul 12, 2012
Messages
15
Hi!

Need some help with a formula to calculate a discount.

20% off all items EXCEPT the highest value item. Where 2 items are same value, only 1 gets the discount. Here's my example:

[table="width: 200, class: grid, align: left"]

[tr]
[td]price[/td]
[td]discount[/td]

[/tr]
[tr]
[td]40[/td]
[td]8[/td]
[/tr]
[tr]
[td]100[/td]
[td]0[/td]
[/tr]
[tr]
[td]100[/td]
[td]20[/td]
[/tr]
[tr]
[td]60[/td]
[td]12[/td]
[/tr]
[/table]

This seems to work when there's no duplicates: =IF(A2=MAX(A2:A4),0,A2*0.2)

But I can't get this to work when there's 2 items with the same highest value.

Any tips on how I can get this working?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
My take on this
=IF(AND(A2=MAX(A$2:A$5),COUNTIF(A$2:A2,MAX(A$2:A$5))=1),0,A2*0.2)
 
Upvote 0
Quite right, I missed the "only 1 gets the discount" part.
 
Upvote 0
That doesn't quite work if there are more than two duplicates or the highest value occurs in the first row. How about:
=IF(AND(A2=MAX(A$2:A$5),COUNTIF(A2:A$2,MAX(A$2:A$5))>1),0,A2*0.2)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,707
Messages
6,174,000
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top