Can I use LARGE and COUNTIFS to exclude values in a range?

rhogsett

New Member
Joined
Jul 23, 2014
Messages
16
I have a list of customer accounts with various past due balances. I would like a formula to rank the accounts based on past due values while excluding specific accounts that have been placed on a separate "Do Not Include" list.

I have used LARGE, which works great until I need to exclude certain accounts from the Top 5 List. I am having difficulty finding/constructing a formula that can achieve the exampled Top 5 Highest Past Due Accounts below.

Please see the sample report below...

Aging Report:
ABC
1Account #Customer NamePast Due Amount
21AAlpha1,000
32BBravo15,000
43CCharlie20,000
54DDelta5,000
65EEcho2,500
76FFoxtrot15,000
87GGolf17,000

<tbody>
</tbody>


...that needs to evaluate the exclusion list below...

Do Not Include:
AB
Excluded Account #Excluded Customer Name
102BBravo
113CCharlie

<tbody>
</tbody>


...in order to produce the results below:

Top 5 Highest Past Due Accounts:
ABC
20Account #Customer NamePast Due Amount
217GGolf17,000
226FFoxtrot15,000
234DDelta5,000
245EEcho2,500
251AAlpha1,000

<tbody>
</tbody>


Any assistance is greatly appreciated! Please let me know where I can provide further clarification.

Thank you,

RGH
 
The Past Due Amount is a total of another worksheet's multiple aging buckets, ie. C2 in first post is a result of "=SUM(AgingWorksheet!G8:O8)"
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
The Past Due Amount is a total of another worksheet's multiple aging buckets, ie. C2 in first post is a result of "=SUM(AgingWorksheet!G8:O8)"

Thanks...

Row\Col
A​
B​
C​
D​
E​
F​
G​
1​
Account #
Customer Name
Past Due Amount
Top N
5​
2​
1A
Alpha
1,000
Top N Adjusted
6​
3​
2B
Bravo
15,000
Top Debt Accounts
Customer
Top Due Amounts
4​
3C
Charlie
20,000
7GGolf
17,000
5​
4D
Delta
5,000
6FFoxtrot
15,000
6​
5E
Echo
2,500
4DDelta
5,000
7​
8H
QAD
1,000
5EEcho
2,500
8​
6F
Foxtrot
15,000
1AAlpha
1,000
9​
7G
Golf
17,000
8HQAD
1,000
10​
11​
12​
Excluded Account #
Excluded Customer Name
13​
2B
Bravo
14​
3C
Charlie

<tbody>
</tbody>


F1: 5 (Top N, adjust as desired.)

In F2 Control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(ISNA(MATCH(A2:A9,A13:A14,0)),
    IF(C2:C9>=LARGE(IF(ISNA(MATCH(A2:A9,A13:A14,0)),$C$2:$C$9),
    MIN(F1,SUM(IF(ISNA(MATCH(A2:A9,A13:A14,0)),1)))),1)))

In E4 control+shift+enter and copy down:
Rich (BB code):
=IF($G4="","",INDEX($A$2:$A$9,SMALL(IF(ISNA(MATCH($A$2:$A$9,$A$13:$A$14,0)),
       IF($C$2:$C$9=$G4,ROW($A$2:$A$9)-ROW($A$2)+1)),COUNTIFS($G$4:G4,G4))))

In F4 just enter and copy down:
Rich (BB code):
=IF($E4="","",VLOOKUP($E4,$A$2:$B$9,2,0))

In G4 control+shift+enter and copy down:
Rich (BB code):
=IF(ROWS($G$4:G4)<=$F$2,LARGE(IF(ISNA(MATCH($A$2:$A$9,$A$13:$A$14,0)),
    $C$2:$C$9),ROWS($G$4:G4)),"")
 
Last edited:
Upvote 0
I'd hoped that DRSteele would respond, since it was his formula. However, since he's away for a bit, I'll give it a shot. I modified his original formula a bit by adding the row number/1000 to each value internally. This insures that there will be no ties, and has the effect that if there is a tie, the account lower down will get the lower numbered rating.

ABCDKLMNOPQ
1Account #Customer NamePast Due AmountRankingExcluded Account #Excluded Customer NameTop 5 Highest Past Due Accounts:
21AAlpha1,00092BBravo9IIndigo175001
32BBravo15,0003CCharlie7GGolf170002
43CCharlie20,0006FFoxtrot150003
54DDelta15,00044DDelta150004
65EEcho2,500811KKilo141235
76FFoxtrot15,0003
87GGolf17,0002Select Ranking
98HHula4,444785EEcho25008
109IIndigo17,5001
1110JJackson5,5556Select NameRanking
1211KKilo14,1235Jackson10JJackson55556

<tbody>
</tbody>
Sheet17

Worksheet Formulas
CellFormula
N2=INDEX(A$2:A$12,MATCH(ROWS($N$2:$N2),$D$2:$D$12,0))
N9=INDEX(A$2:A$12,MATCH($M$9,$D$2:$D$12,0))
N12=INDEX(A$2:A$12,MATCH($M$12,$B$2:$B$12,0))

<tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
D2{=IF(ISNA(MATCH(A2,$K$2:$K$3,0)),SUMPRODUCT(--(C2+ROW(C2)/1000<$C$2:$C$12+ROW($C$2:$C$12)/1000),--ISNA(MATCH($A$2:$A$12,$K$2:$K$3,0)))+1,"")}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



Put the D2 formula in and confirm with Control+Shift+Enter. Copy it and paste it down the column.

The rest of the formulas are now just lookups. Put the N2 formula in and paste it to N2:Q6. Put the N9 formula in and paste to O9:Q9. Put the N12 formula in and paste to O12:Q12.

Now the top 5 accounts will automatically populate N2:Q6. You can select the ranking you want to see by putting a number in M9. You can select the name you want to see by putting it in M12.

Hope this helps.
 
Last edited:
Upvote 0
EricW I think I've lost the plot here. I thought what I'd originally proposed and then amended to account for tied figures was working on my computer. Then came all kinds of new suggestions and I didn't want to add more noise.
 
Upvote 0
Eric,

Thank you. I keep receiving the #Value with the D2 formula. Any thought what may be causing this?
 
Upvote 0
Best guess is that you have some non-numeric data in your amount range. Empty cells are OK, cells with spaces are not. You can try to find those and clean them up, or you can use this array function:

=IF(ISNA(MATCH(A2,$K$2:$K$3,0)),SUMPRODUCT(--(IFERROR(C2+ROW(C2)/1000,0)< IFERROR($C$2:$C$12+ROW($C$2:$C$12)/1000,0)),--ISNA(MATCH($A$2:$A$12,$K$2:$K$3,0)))+1,"")

which ignores non-numeric data.
 
Upvote 0
Eric,

Thank you. I keep receiving the #Value with the D2 formula. Any thought what may be causing this?

I may have figured out the issue. In the formula, since the number of accounts on the Aging Report fluctuate, I extended the range for Account # (Column A) and Amount Past Due (Column C) beyond $C$12. This appears to be causing the "#Value" error.

This does not help solve the issue, but at least (I think) the issue is identified.
 
Upvote 0
Best guess is that you have some non-numeric data in your amount range. Empty cells are OK, cells with spaces are not. You can try to find those and clean them up, or you can use this array function:

=IF(ISNA(MATCH(A2,$K$2:$K$3,0)),SUMPRODUCT(--(IFERROR(C2+ROW(C2)/1000,0)< IFERROR($C$2:$C$12+ROW($C$2:$C$12)/1000,0)),--ISNA(MATCH($A$2:$A$12,$K$2:$K$3,0)))+1,"")

which ignores non-numeric data.

This worked perfectly, thank you!
 
Upvote 0

Forum statistics

Threads
1,216,117
Messages
6,128,937
Members
449,480
Latest member
yesitisasport

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