Using COUNTIFS to Rank Within Nested IF, THEN

diderooy

New Member
Joined
Jan 9, 2014
Messages
34
Office Version
  1. 365
Platform
  1. Windows
I see the variety of much more complicated questions being asked here and am a little embarrassed at how much simpler mine sounds. I'm sorry about that. But I can't seem to solve this on my own.

I want to rank a grouping within a larger table of values based on their sale counts. The following conditions must be met or are involved in the rankings:
  • I need an ordering of each region for each year, within a table of many regions covering many years; salespeople are ordered by year and then by name, not by group.
  • The #1 and #2 rankings are awarded to salespeople based on other criteria.
  • The #3 through #n rankings are based on sales count.
The formula I thought would work to achieve this in the RANKING column was:

Excel Formula:
=IF([@[Year End Award]]="Y",1,
IF([@[6-Month Award]]="Y",2,
IF(AND([@[Year End Award]]="",[@[6-Month Award]]=""),COUNTIFS($A$2:$A$137,A4,$I$2:$I$137,I4,$F$2:$F$137,">"&F4)+1)))

...where applying it would give me the following rankings for a filtered group in a filtered year:

YearNameSalesYear End Award6-Month AwardRANKING
2022Alfa38
2022Bravo29
2022Charlie29
2022Delta111
2022Echo73
2022Foxtrot65
2022Golf111
2022Hotel65
2022India8Y2
2022Juliett7Y1
2022Kilo73
2022Lima47

What I actually got was:

YearNameSalesYear End Award6-Month AwardRANKING
2022Alfa38
2022Bravo29
2022Charlie29
2022Delta111
2022Echo72
2022Foxtrot65
2022Golf111
2022Hotel65
2022India8Y2
2022Juliett7Y1
2022Kilo72
2022Lima47

All of it seems correct except for the rankings for Echo and Kilo, who should be =3rd. I can see that they have the same number of sales as India, but they do not have any award, so the highest they can be ranked is 3. The other rankings for everyone else appear to be correct, and ties are acceptable.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Would adding a minimum formula work, since they should start with 3?
Excel Formula:
=IF([@[Year End Award]]="Y",1,
IF([@[6-Month Award]]="Y",2,
IF(AND([@[Year End Award]]="",[@[6-Month Award]]=""),MIN(3,COUNTIFS($A$2:$A$137,A4,$I$2:$I$137,I4,$F$2:$F$137,">"&F4)+1))))

What's in the I column? I can't really test the formula without knowing what data is being used in the formula.
 
Last edited:
Upvote 0
Solution
Actually, MIN didn't work, but MAX did. Man you people are amazing...I wouldn't have thought of that for another couple weeks.

Sorry about that, Vogateer; I guess I didn't fudge enough of my own data...the portions within the COUNTIFS are making sure the year matches (column A), the group matches (column I) and the sales count matches (column F).
 
Upvote 0
Actually, MIN didn't work, but MAX did. Man you people are amazing...I wouldn't have thought of that for another couple weeks.

Sorry about that, Vogateer; I guess I didn't fudge enough of my own data...the portions within the COUNTIFS are making sure the year matches (column A), the group matches (column I) and the sales count matches (column F).
Glad you caught my silly error!
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,115
Members
453,021
Latest member
Justyna P

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