Ranking with sumproduct & countif with extra conditions

azdraon

New Member
Joined
Aug 16, 2021
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hey everyone. I have been stuck on this issue for a few days now. I have multiple criteria for the ranking, "State" and "Type". And I want it to be ranked based on the "Share". This is just a sample and actually have hundred of rows. I have figured it out so that it filters to the State and Type for the SUMPRODUCT(). But when I try to throw in a COUNTIF() I get crazy decimal places (see Group Rank (calc)).

Here is my formula. My desired result would be a rank with repeating values. Actually the decimals go out much further, and I can't symply "ROUND()" that I can figure out to resolve this issue.

Group Rank (calc) =SUMPRODUCT((--([@State]=[State])),(--([@[Line Of Business]]=[Line Of Business])),(--([@[Share]]<=[Share]))/COUNTIF([Share],[Share]))

StateLine of BusinessShareGroup Rank (calc)
IAHomeowners
2303​
1.3​
IAHomeowners
257​
7.1​
IAHomeowners
264​
6.1​
IAHomeowners
264​
6.1​
IAHomeowners
264​
6.1​
IAHomeowners
335​
5.2​
IAHomeowners
335​
5.2​
IAHomeowners
355​
4.6​
IAHomeowners
355​
4.6​
IAHomeowners
500​
4.3​
IAHomeowners
899​
3.3​
IAHomeowners
899​
3.3​
IAHomeowners
899​
3.3​
IAHomeowners
899​
3.3​
IAHomeowners
1162​
2.3​
IAHomeowners
1162​
2.3​
IAHomeowners
1162​
2.3​
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Using Office 365 it works out of the box. Seems like you found a solution that is not compatible with your version of Excel.

Book2
ABCD
1StateLine of BusinessShareGroup Rank
2IAHomeowners11628
3IAHomeowners11628
4IAHomeowners11628
5IAHomeowners23037
6IAHomeowners2576
7IAHomeowners2645
8IAHomeowners2645
9IAHomeowners2645
10IAHomeowners3354
11IAHomeowners3354
12IAHomeowners3553
13IAHomeowners3553
14IAHomeowners5002
15IAHomeowners8991
16IAHomeowners8991
17IAHomeowners8991
18IAHomeowners8991
Sheet1
Cell Formulas
RangeFormula
D2:D18D2=SUMPRODUCT((--([@State]=[State])),(--([@[Line of Business]]=[Line of Business])),(--([@Share]<=[Share]))/COUNTIF([Share],[Share]))
 
Upvote 0
Using Office 365 it works out of the box. Seems like you found a solution that is not compatible with your version of Excel.

Book2
ABCD
1StateLine of BusinessShareGroup Rank
2IAHomeowners11628
3IAHomeowners11628
4IAHomeowners11628
5IAHomeowners23037
6IAHomeowners2576
7IAHomeowners2645
8IAHomeowners2645
9IAHomeowners2645
10IAHomeowners3354
11IAHomeowners3354
12IAHomeowners3553
13IAHomeowners3553
14IAHomeowners5002
15IAHomeowners8991
16IAHomeowners8991
17IAHomeowners8991
18IAHomeowners8991
Sheet1
Cell Formulas
RangeFormula
D2:D18D2=SUMPRODUCT((--([@State]=[State])),(--([@[Line of Business]]=[Line of Business])),(--([@Share]<=[Share]))/COUNTIF([Share],[Share]))
What The?!?!? It does seem to work on smaller amounts of data. I would be curious if I was able to upload the entire data set if it still works for you. I will need ot use another computer though.
 
Upvote 0
What The?!?!? It does seem to work on smaller amounts of data. I would be curious if I was able to upload the entire data set if it still works for you. I will need ot use another computer though.
Yeah
Using Office 365 it works out of the box. Seems like you found a solution that is not compatible with your version of Excel.

Book2
ABCD
1StateLine of BusinessShareGroup Rank
2IAHomeowners11628
3IAHomeowners11628
4IAHomeowners11628
5IAHomeowners23037
6IAHomeowners2576
7IAHomeowners2645
8IAHomeowners2645
9IAHomeowners2645
10IAHomeowners3354
11IAHomeowners3354
12IAHomeowners3553
13IAHomeowners3553
14IAHomeowners5002
15IAHomeowners8991
16IAHomeowners8991
17IAHomeowners8991
18IAHomeowners8991
Sheet1
Cell Formulas
RangeFormula
D2:D18D2=SUMPRODUCT((--([@State]=[State])),(--([@[Line of Business]]=[Line of Business])),(--([@Share]<=[Share]))/COUNTIF([Share],[Share]))
yeah, the rankings you display arent correct either. Its all over the place like mine.
 
Upvote 0
How about
+Fluff 1.xlsm
ABCD
1StateLine of BusinessShareGroup Rank
2IAHomeowners23031
3IAHomeowners11622
4IAHomeowners11622
5IAHomeowners11622
6IAHomeowners8995
7IAHomeowners8995
8IAHomeowners8995
9IAHomeowners3558
10IAHomeowners3359
11IAHomeowners26410
12IAHomeowners26410
13IAHomeowners25712
14IArent8991
15IArent5002
16IBHomeowners3551
17IBrent3351
18IBrent2642
Lists
Cell Formulas
RangeFormula
D2:D18D2=COUNTIFS([State],[@State],[Line of Business],[@[Line of Business]],[Share],">"&[@Share])+1
 
Upvote 0
@Crystalyzer do your results actually make sense to you?
Since you mentioned it, no. So went back and found that the data I copied in wasn't being handled as numeric in all cases so I corrected this and the results are as follows:
Book2
ABCD
2IAHomeowners2,3031
3IAHomeowners1,1622
4IAHomeowners1,1622
5IAHomeowners1,1622
6IAHomeowners8993
7IAHomeowners8993
8IAHomeowners8993
9IAHomeowners8993
10IAHomeowners5004
11IAHomeowners3555
12IAHomeowners3555
13IAHomeowners3356
14IAHomeowners3356
15IAHomeowners2647
16IAHomeowners2647
17IAHomeowners2647
18IAHomeowners2578
Sheet1
Cell Formulas
RangeFormula
D2:D18D2=SUMPRODUCT((--([@State]=[State])),(--([@[Line of Business]]=[Line of Business])),(--([@Share]<=[Share])/COUNTIF([Share],[Share])))


This makes more sense since it is now ranking by the Share in Descending order.
 
Upvote 0
How about
+Fluff 1.xlsm
ABCD
1StateLine of BusinessShareGroup Rank
2IAHomeowners23031
3IAHomeowners11622
4IAHomeowners11622
5IAHomeowners11622
6IAHomeowners8995
7IAHomeowners8995
8IAHomeowners8995
9IAHomeowners3558
10IAHomeowners3359
11IAHomeowners26410
12IAHomeowners26410
13IAHomeowners25712
14IArent8991
15IArent5002
16IBHomeowners3551
17IBrent3351
18IBrent2642
Lists
Cell Formulas
RangeFormula
D2:D18D2=COUNTIFS([State],[@State],[Line of Business],[@[Line of Business]],[Share],">"&[@Share])+1
Unfortunately I am trying to get it so it repeats Rank if values are equal to each other. This appears to then not give be duplicate rank values.
 
Upvote 0
It does for me, if you look at rows 3,4 & 5 they are all ranked 2
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,156
Members
448,948
Latest member
spamiki

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