Find the Nth Largest with Multiple Criteria

*shudder*

Well-known Member
Joined
Aug 20, 2009
Messages
510
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I would like to search a table and return the Nth largest number between to dates, whilst also matching the customers name and/or if the order value is over a certain amount.

Sample data set as follows:

Order_NameOrder_DateOrder_Value
Smith
01/01/2022​
1,000.00​
Smith
01/02/2022​
2,000.00​
Smith
01/04/2022​
3,000.00​
Jones
01/01/2022​
4,000.00​
Jones
01/02/2022​
5,000.00​
Jones
01/04/2022​
6,000.00​
Jones
01/01/2022​
7,000.00​
Smith
01/02/2022​
8,000.00​
Kaur
01/04/2022​
9,000.00​
Singh
01/01/2022​
10,000.00​
Kaur
01/02/2022​
11,000.00​
Kaur
01/04/2022​
12,000.00​
Smith
01/01/2023​
12,000.00​
Smith
01/02/2023​
11,000.00​
Smith
01/04/2023​
10,000.00​
Jones
01/01/2023​
9,000.00​
Jones
01/02/2023​
8,000.00​
Jones
01/04/2023​
7,000.00​
Jones
01/01/2023​
6,000.00​
Smith
01/02/2023​
5,000.00​
Kaur
01/04/2023​
4,000.00​
Singh
01/01/2023​
3,000.00​
Kaur
01/02/2023​
2,000.00​
Kaur
01/04/2023​
1,000.00​

Expected results:
NameSmithNameKaur
Start Period
01/01/2022​
Start Period
01/01/2023​
End Period
31/12/2022​
End Period
31/12/2023​
Orders Over
0​
Order Value
1500​
ResultResult
1st Highest
8000​
1st Highest
4000​
2nd Highest
3000​
2nd Highest
2000​
3rd Highest
2000​
3rd HighestNil

I am using Excel 2016.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
The formula for the nth largest is =LARGE(range, cell with nth to find) IE =LARGE($C5:$G5,I$4) where $C5:$G5 is the range and $I4 contains the nth number
 
Upvote 0
How about
Fluff.xlsm
ABCDE
1Order_NameOrder_DateOrder_Value
2Smith01/01/20221,000.00
3Smith01/02/20222,000.00
4Smith01/04/20223,000.00
5Jones01/01/20224,000.00
6Jones01/02/20225,000.00
7Jones01/04/20226,000.00
8Jones01/01/20227,000.00
9Smith01/02/20228,000.00
10Kaur01/04/20229,000.00
11Singh01/01/202210,000.00
12Kaur01/02/202211,000.00
13Kaur01/04/202212,000.00
14Smith01/01/202312,000.00
15Smith01/02/202311,000.00
16Smith01/04/202310,000.00
17Jones01/01/20239,000.00
18Jones01/02/20238,000.00
19Jones01/04/20237,000.00
20Jones01/01/20236,000.00
21Smith01/02/20235,000.00
22Kaur01/04/20234,000.00
23Singh01/01/20233,000.00
24Kaur01/02/20232,000.00
25Kaur01/04/20231,000.00
26
27Expected results:
28NameSmithNameKaur
29Start Period01/01/2022Start Period01/01/2023
30End Period31/12/2022End Period31/12/2023
31Orders Over0Order Value1500
32
33ResultResult
341st Highest80001st Highest4000
352nd Highest30002nd Highest2000
363rd Highest20003rd HighestNil
sheet6
Cell Formulas
RangeFormula
B34:B36B34=IFERROR(AGGREGATE(14,6,$C$2:$C$25/($A$2:$A$25=$B$28)/($B$2:$B$25>=$B$29)/($B$2:$B$25<=$B$30)/($C$2:$C$25>$B$31),ROWS(B$34:B34)),"Nil")
E34:E36E34=IFERROR(AGGREGATE(14,6,$C$2:$C$25/($A$2:$A$25=$E$28)/($B$2:$B$25>=$E$29)/($B$2:$B$25<=$E$30)/($C$2:$C$25>$E$31),ROWS(B$34:B34)),"Nil")
 
Upvote 0
Solution
The formula for the nth largest is =LARGE(range, cell with nth to find) IE =LARGE($C5:$G5,I$4) where $C5:$G5 is the range and $I4 contains the nth number

Thanks, that only provides the nth largest number rather than also matching the additional criteria.

I have spent quite a few hours searching and trying to combine the large function with others to get the desired result to no avail. The closest I have got is this:

=LARGE(IF(Table1[Order_Name]=Customer,IF(Table1[Order_Date]>=Date_Start,Table1[Order_Total])),1)

However, this doesn't incorporate the upper date range and I cannot figure out how to amend the formula to incorporate this i.e. the following just returns #NUM! result:

=LARGE(IF(Table1[Order_Name]=Customer,IF(AND(Table1[Order_Date]>=Date_Start,Table1[Order_Date]<=Date_End),Table1[Order_Total])),1)

The above also doesn't take into consideration to only return orders above x value.
 
Upvote 0
Just did it for the 1st for smith
1697548304128.png
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,999
Members
452,373
Latest member
TimReeks

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