Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
user35131
Helper III
Helper III

How can I set a rank index based on earliest date while grouped by on id using variables?

I have a table that looks like this 

 

IDNameDate
1Johnson12/03/2021
1Johnson01/05/2022
2Davis04/15/2021
2Davis08/12/2021
3Williams12/14/2021

 

I would like to create a table that looks like this 

 

IDNameDateRank Order
1Johnson12/03/20211
1Johnson01/05/20222
2Davis04/15/20211
2Davis08/12/20212
3Williams12/14/20211

 

Currently I have this formula. This gives me the wrong answer cause it ranks by date, but I know i'm close. I tried to set a group by as a second variable but i didn't know how to add it in the arguments or Rank. I'm trying to do it within the context of the variable chain.

 

 

Final Table = 

Var Table=

DISTINCT(SELECTCOLUMNS('OriginalTable',"ID",'Orginal'[ID],"Name",'OriginalTable'[Name],"Date",'OriginalTable'[Date]))

var Table2 =

ADDCOLUMNS(Table,"Rank Order", RANKX(OriginalTable,[Date],,ASC,Dense))


return Table2

 

.

 

1 ACCEPTED SOLUTION
user35131
Helper III
Helper III

ADDCOLUMNS(SQL,"Rank Order", RANKX(FILTER(OriginalTable,[ID]=EARLIER([ID])),[Date],,ASC,Dense))
 
It turns out its this. I figured it out.

View solution in original post

1 REPLY 1
user35131
Helper III
Helper III

ADDCOLUMNS(SQL,"Rank Order", RANKX(FILTER(OriginalTable,[ID]=EARLIER([ID])),[Date],,ASC,Dense))
 
It turns out its this. I figured it out.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors