RankX Filter Earlier

rsj88

New Member
Joined
Feb 20, 2018
Messages
38
Hi,

I have the below data set

DateGroupNameRank
01/01/19ATim1
02/01/19ATim2
04/01/19ADave1
05/01/19APeter1
04/01/19CTim 1
07/01/19ADave2
07/01/19BTim1
03/01/19ATim3

I trying to do a Rankx Filter Earlier to rank the name by group by the earlierst date. (Rank above is how it should be). Any Ideas?

Thanks in advance
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi,

You might want to try to use this calculated column -

Rich (BB code):
cRank = 
    var ThisGroup = TableRank[Group]
    var ThisName = TableRank[Name]
    var ThisDate = TableRank[Date]
    var t = FILTER(TableRank, 
                TableRank[Group] = ThisGroup 
                && TableRank[Name] = ThisName
                && TableRank[Date] < ThisDate)
return
    COUNTROWS(t) + 1

1587577494210.png
 
Upvote 0
Hi,

You might want to try to use this calculated column -

Rich (BB code):
cRank =
    var ThisGroup = TableRank[Group]
    var ThisName = TableRank[Name]
    var ThisDate = TableRank[Date]
    var t = FILTER(TableRank,
                TableRank[Group] = ThisGroup
                && TableRank[Name] = ThisName
                && TableRank[Date] < ThisDate)
return
    COUNTROWS(t) + 1

View attachment 12082
Hi.....JustynaMK

This is almost exactly what I need. Your code above is ranking the date in ASC order, What do I have to change to rank in DESC order
Thank
 
Upvote 0
Hi, sure - as far as I remember, the purpose of the first table was to rank Name & Group by a Date field. For example, Tim in group A (I have added a column that combines these two together) has three records, and they are ranked by date (from oldest to newest).

1616164497673.png


In order to rank from newest to oldest, you literally just need to change "<" to ">":

1616164607625.png
 
Upvote 0

Forum statistics

Threads
1,225,626
Messages
6,186,087
Members
453,336
Latest member
Excelnoob223

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