Ranking with SUMPRODUCT to ignore blanks

Celticshadow

Active Member
Joined
Aug 16, 2010
Messages
373
Hi All

I am ranking data using the below formula but if a cell is blank then I would like that cell ignored and only rank cells that contain data

{=SUMPRODUCT(--($A$2:$A$10243=$A2),--(IR$2:IR$10243>IR2))+1}

The A2:A10243 is a column containing an id number for the data held in cells IR2:IR10243.

Thanks in advance.

Regards
 

Some videos you may like

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Celticshadow

Active Member
Joined
Aug 16, 2010
Messages
373
Hi All

I am ranking data using the below formula but if a cell is blank then I would like that cell ignored and only rank cells that contain data

{=SUMPRODUCT(--($A$2:$A$10243=$A2),--(IR$2:IR$10243>IR2))+1}

The A2:A10243 is a column containing an id number for the data held in cells IR2:IR10243.

Thanks in advance.

Regards

Hi All

Perhaps an example may help a little


ID
Data
Rank
1
44
2
1
46
1
1
1
32
3
2
34
2
2
56
1
2
2
2
18
3

<tbody>
</tbody>


Hope that helps and many thanks.

Regards
 

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
16,407
Hi

Maybe...

Excel 2007 or higher
=IF(IR2<>"",COUNTIFS($A$2:$A$10243,A2,$IR$2:$IR$10243,">"&IR2)+1,"")

Excel 2003
=IF(IR2<>"",SUMPRODUCT(--($A$2:$A$10243=A2),--($IR$2:$IR$10243>IR2))+1,"")

M.
 

Celticshadow

Active Member
Joined
Aug 16, 2010
Messages
373
Hi Marcelo

Once again a perfect solution. Many thanks for your help it is very much appreciated.

Regards
 

Mr_Lucky

New Member
Joined
Jul 31, 2019
Messages
27
I have used this formula to not rank if the reference cell was blank and it works well.

Then I have tried to include two blank condition =IF(OR(A2<>””,B2<>””),SUMPRODUCT...

The problem with this is that the second blank condition still adds a ranking number even though the reference cell is blank. Is there a way that I can apply a second blank condition to the formula.

Any help would be appreciated.
 

Mr_Lucky

New Member
Joined
Jul 31, 2019
Messages
27
Thanks for reply. I have tried "AND" and it does not rank if either of the blank conditions are met.

The problem now is that if the second blank condition is met then the ranking numbers are not adjusted. Example ranking 1,2,3,4,6. 5 is missing because the second blank condition has been met but the ranking sequence is not adjusted.

=IF(AND(E3<>"",K3<>""), SUMPRODUCT(--(E3=$E$3:$E$42),--(G3<$G$3:$G$42))+1,"")

Any ideas in how to fix this?
 

theBardd

Rules violation
Joined
Jan 21, 2012
Messages
912
Thanks for reply. I have tried "AND" and it does not rank if either of the blank conditions are met.

The problem now is that if the second blank condition is met then the ranking numbers are not adjusted. Example ranking 1,2,3,4,6. 5 is missing because the second blank condition has been met but the ranking sequence is not adjusted.

=IF(AND(E3<>"",K3<>""), SUMPRODUCT(--(E3=$E$3:$E$42),--(G3<$G$3:$G$42))+1,"")

Any ideas in how to fix this?

Try OR instead of AND
 

Mr_Lucky

New Member
Joined
Jul 31, 2019
Messages
27
Try OR instead of AND

I have tried "OR" but than neither of the blank conditions are met. I have also tried (AND(OR and (OR(AND but none of them work.

=IF(AND(E3<>"",K3<>""), SUMPRODUCT(--(E3=$E$3:$E$42),--(G3<$G$3:$G$42))+1,"")

=IF(OR(E3<>"",K3<>""), SUMPRODUCT(--(E3=$E$3:$E$42),--(G3<$G$3:$G$42))+1,"")

=IF(AND(OR(E3<>"",K3<>"")), SUMPRODUCT(--(E3=$E$3:$E$42),--(G3<$G$3:$G$42))+1,"")

=IF(OR(AND(E3<>"",K3<>"")), SUMPRODUCT(--(E3=$E$3:$E$42),--(G3<$G$3:$G$42))+1,"")
 

Watch MrExcel Video

Forum statistics

Threads
1,122,483
Messages
5,596,405
Members
414,064
Latest member
Duncthegreat

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
Top