2nd Largest Value With Criteria and avoiding duplicates

dannycabrera

New Member
Joined
Apr 6, 2018
Messages
5
Hello,

I need to figure out how to grab the 2nd largest value with criteria and avoiding duplicates.

essentially i have a list of transactions and I need to say what is this customer's last time they ordered and 2nd to last time they ordered.

Thank you so much!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I am looking to get the 2nd Largest Value with Criteria Avoiding Duplicates,

essentially I want to find out every customer in my records their min, max and 2nd to max ship date

This was my original take on it, '={LARGE(IF([Column2]=[@Column2],IF([Ship Date]<[@MAX],[Ship Date]),[@MAX]),2)}
SHIP DATECUSTOMERMINMAX2ND MAX
1/1/2013ABC1/1/20131/3/20131/2/2013
1/2/2013ABC1/1/20131/3/20131/2/2013
1/2/2013ABC1/1/20131/3/20131/2/2013
1/3/2013ABC1/1/20131/3/20131/2/2013
1/3/2013ABC1/1/20131/3/20131/2/2013
1/2/2013DEF1/2/20131/5/20131/4/2013
1/2/2013DEF
1/4/2013DEF
1/4/2013DEF
1/5/2013DEF
1/5/2013DEF

<tbody style="border-collapse: collapse; border-spacing: 0px 0px; font-size: 13px; margin-bottom: 0px;">
</tbody>

 
Upvote 0
Figured it out I think,

'{=LARGE(IF([Column2]=[@Column2],IF([Ship Date]<[@MAX],[Ship Date])),1)}

Thanks anyway, and sorry for posting twice, it was a mistake I'm new here :)
 
Upvote 0
so this ended up being my formula is there anything that works faster than this? it is really slow

{=IF(ISERROR(LARGE(IF([Column2]=[@Column2],IF([Ship Date]<[@MAX],[Ship Date])),1)),[@MAX],LARGE(IF([Column2]=[@Column2],IF([Ship Date]<[@MAX],[Ship Date])),1))}
 
Upvote 0
Row\Col
A​
B​
C​
D​
E​
1​
SHIP DATECUSTOMERminmax2nd max
2​
1/1/2013
ABC
1/1/2013
1/3/2013
1/2/2013
3​
1/2/2013
ABC
1/1/2013
1/3/2013
1/2/2013
4​
1/2/2013
ABC
1/1/2013
1/3/2013
1/2/2013
5​
1/3/2013
ABC
1/1/2013
1/3/2013
1/2/2013
6​
1/3/2013
ABC
1/1/2013
1/3/2013
1/2/2013
7​
1/2/2013
DEF
1/2/2013
1/5/2013
1/4/2013
8​
1/2/2013
DEF
1/2/2013
1/5/2013
1/4/2013
9​
1/4/2013
DEF
1/2/2013
1/5/2013
1/4/2013
10​
1/4/2013
DEF
1/2/2013
1/5/2013
1/4/2013
11​
1/5/2013
DEF
1/2/2013
1/5/2013
1/4/2013
12​
1/5/2013
DEF
1/2/2013
1/5/2013
1/4/2013

If we don't use the Table functionality...

In C2 control+shift+enter, not just enter, and copy down:

=MIN(IF($B$2:$B$12=$B2,$A$2:$A$12))

If available to you, with MINIFS just enter and copy down:

=MINIFS($A$2:$A$12,$B$2:$B$12,$B2)

In D2 control+shift+enter and copy down:

=MAX(IF($B$2:$B$12=$B2,$A$2:$A$12))

If available to you, with MAXIFS just enter and copy down:

=MAXIFS($A$2:$A$12,$B$2:$B$12,$B2)

In E2 control+shift+enter and copy down:

=MAX($D2,MAX(IF($B$2:$B$12=$B2,IF($A$2:$A$12 < $D2,$A$2:$A$12))))

If available to you, with MAXIFS just enter and copy down:

=MAX($D2,MAXIFS($A$2:$A$12,$B$2:$B$12, $B2,$A$2:$A$12,"<"&$D2))

With Table functionality...

In C2 control+shift+enter:

=MIN(IF([CUSTOMER]=[@CUSTOMER],[SHIP DATE]))

or using MINIFS, just enter:

=MINIFS([SHIP DATE],[CUSTOMER],[@CUSTOMER])

In D2 control+shift+enter:

=MAX(IF([CUSTOMER]=[@CUSTOMER],[SHIP DATE]))

or using MAXIFS, just enter:

=MAXIFS([SHIP DATE],[CUSTOMER],[@CUSTOMER])

In E2 control+shift+enter:

=MAX([@max],MAX(IF([CUSTOMER]=$B2,IF([SHIP DATE] < [@max],[SHIP DATE]))))

or using MAXIFS, just enter:

=MAX([@max],MAXIFS([SHIP DATE],[CUSTOMER],[@CUSTOMER],[SHIP DATE],"<"&[@max]))
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,665
Members
449,114
Latest member
aides

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