It would be awesome if RANKIF existed. But it doesn't. So I need help!

Painzstake

New Member
Joined
Mar 25, 2014
Messages
10
I have been working on this ranking problem for a while now. I've tried multiple combinations of COUNTIF and SUMPRODUCT, but I can't seem to get my formula to work! I thought I'd jump back into these forums to see if anybody was up for the challenge?

Problem: column C needs to contain dates ranked from column A. These dates are to be ranked by the groups in Column B in the following manner; if B is "Old", then rank as descending whole values; if B is "New", then rank as ascending decimal values; if B is "Posted", then leave blank.

For context: the final formula is going to be arrayed from C2.

This table shows the desired result:

[TABLE="class: grid, width: 300"]
<tbody>[TR]
[TD][/TD]
[TD="align: center"]A
[/TD]
[TD="align: center"]B
[/TD]
[TD="align: center"]C
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]Date
[/TD]
[TD]Is
[/TD]
[TD]Order
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
10/02/2018 16:41:00
[/TD]
[TD]Old
[/TD]
[TD]3
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
14/02/2018 18:02:00
[/TD]
[TD]Posted
[/TD]
[TD]""
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
17/02/2018 21:59:00
[/TD]
[TD]Posted
[/TD]
[TD]""
[/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD]<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
17/02/2018 22:40:00
[/TD]
[TD]Old
[/TD]
[TD]2
[/TD]
[/TR]
[TR]
[TD]6
[/TD]
[TD]<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
21/02/2018 22:49:00
[/TD]
[TD]Posted
[/TD]
[TD]""
[/TD]
[/TR]
[TR]
[TD]7
[/TD]
[TD]<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
22/02/2018 22:11:00
[/TD]
[TD]Old
[/TD]
[TD]1
[/TD]
[/TR]
[TR]
[TD]8
[/TD]
[TD]<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
24/02/2018 10:36:00
[/TD]
[TD]New
[/TD]
[TD].1
[/TD]
[/TR]
[TR]
[TD]9
[/TD]
[TD]<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
17/02/2018 20:36:00
[/TD]
[TD]New
[/TD]
[TD].2
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I used a table:


EZkd58f.jpg
 
Upvote 0
Alternatively:


Book1
ABCD
1DateIsOrderOrder
210/02/2018 16:41Old33
314/02/2018 18:02Posted
417/02/2018 21:59Posted
517/02/2018 22:40Old22
621/02/2018 22:49Posted
722/02/2018 22:11Old11
824/02/2018 10:36New0.20.1
917/02/2018 20:36New0.10.2
Sheet1
Cell Formulas
RangeFormula
C2=IF($B2="Old",COUNTIFS($B$2:$B$9,"Old",$A$2:$A$9,">"&$A2)+1,IF($B2="New",(COUNTIFS($B$2:$B$9,"New",$A$2:$A$9,"<"&$A2)+1)/10,""))
D2=IF($B2="Old",COUNTIFS($B$2:$B$9,"Old",$A$2:$A$9,">"&$A2)+1,IF($B2="New",(COUNTIFS($B$2:$B$9,"New",$A$2:$A$9,">"&$A2)+1)/10,""))


Ranking "New" values in ascending order should give the results as posted in Column C, not as your example. If you want this the other way then take the formula from column D.

WBD
 
Upvote 0
Alternatively:

ABCD
DateIsOrderOrder
Old
Posted
Posted
Old
Posted
Old
New
New

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]10/02/2018 16:41[/TD]

[TD="align: right"]3[/TD]
[TD="align: right"]3[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"]14/02/2018 18:02[/TD]

[TD="align: center"]4[/TD]
[TD="align: right"]17/02/2018 21:59[/TD]

[TD="align: center"]5[/TD]
[TD="align: right"]17/02/2018 22:40[/TD]

[TD="align: right"]2[/TD]
[TD="align: right"]2[/TD]

[TD="align: center"]6[/TD]
[TD="align: right"]21/02/2018 22:49[/TD]

[TD="align: center"]7[/TD]
[TD="align: right"]22/02/2018 22:11[/TD]

[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]

[TD="align: center"]8[/TD]
[TD="align: right"]24/02/2018 10:36[/TD]

[TD="align: right"]0.2[/TD]
[TD="align: right"]0.1[/TD]

[TD="align: center"]9[/TD]
[TD="align: right"]17/02/2018 20:36[/TD]

[TD="align: right"]0.1[/TD]
[TD="align: right"]0.2[/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C2[/TH]
[TD="align: left"]=IF($B2="Old",COUNTIFS($B$2:$B$9,"Old",$A$2:$A$9,">"&$A2)+1,IF($B2="New",(COUNTIFS($B$2:$B$9,"New",$A$2:$A$9,"<"&$A2)+1)/10,""))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D2[/TH]
[TD="align: left"]=IF($B2="Old",COUNTIFS($B$2:$B$9,"Old",$A$2:$A$9,">"&$A2)+1,IF($B2="New",(COUNTIFS($B$2:$B$9,"New",$A$2:$A$9,">"&$A2)+1)/10,""))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]



Ranking "New" values in ascending order should give the results as posted in Column C, not as your example. If you want this the other way then take the formula from column D.

WBD

Wideboydixon, this is exactly what I was looking for. I appreciate you taking the time to help me out with this. It's being doing my head in for the past few days. The formula works great!

Special thanks to Worf for his contribution too! I'm amazed people like you guys take the time to help strangers with their excel problems.

All the best,


Painzstake
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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