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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
saranee
Helper I
Helper I

Dynamic ranking based on date

Hi all,

 

Request your help on this.

 

We are basically having a table with Name,Date and based on date we are assigning Rank.

We have calculated column to calculate rank:RANKX(FILTER(Table1,Table1[Name]=EARLIER(Table1[Name])),Table1[Date],,DESC,Dense)

 

rank1.png

 

But when we are changing date filter i.e going to back date rank is not getting updated accordingly.For e.g for A when we changed date filter from 15 feb to 8 Feb then A on 3rd Feb will be having rank as 1 but still it remains 2.

 

rank2.png

 

Please can we have a solution for this.

 

Thanks,
saranee

1 ACCEPTED SOLUTION

@saranee

 

Try this MEASURE for dynamic RANKING

 

RANK =
RANKX (
    FILTER ( ALLSELECTED ( Table1 ), Table1[Name] = SELECTEDVALUE ( Table1[Name] ) ),
    CALCULATE ( SELECTEDVALUE ( Table1[Date] ) ),
    ,
    DESC,
    DENSE
)

Regards
Zubair

Please try my custom visuals

View solution in original post

11 REPLIES 11
Anonymous
Not applicable

Hello,

 

I want to create a new column ranking on the basis of certain values in a column (AHT). However, I want the ranking to be filtered according to the Date. I mean it should rank the values in AHT, if I filter the date to Jan-22 then it should give me ranking on the basis of date and not for overall dates.

 

EcodeEnameAHTDate
45654A382Jan-22
45655B289Jan-22
45654A351Feb-22

 

 

 

Hi,

Download my PBI file from here.  Let me know if this is working well.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

 

Try this measures

 

Date value=SUM(Table1[Date])

Rank=RANKX(ALL(Table1[Date]),[Date value])

 

If this does not help, then share the link from where i can download your file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ricardocamargos
Continued Contributor
Continued Contributor

Hi @saranee,

 

Why don't u use measure instead of calculated column ?

 

Ricardo

HI Richard,

 

We will be then unable to use EARLIER in measure.Please can you suggest some alternative as we want seperate set of names and then trying to find rank.

 

Thanks,

saranee

Hi @saranee,

 

Try this code:

 

_Index =
IF(ISBLANK(CALCULATE(COUNTROWS(Table2); FILTER(ALLSELECTED(Table2[Date]); Table2[Date] < MAX(Table2[Date]))));
1;
CALCULATE(COUNTROWS(Table2); FILTER(ALLEXCEPT(Table2; Table2[Name]); Table2[Date] < MAX(Table2[Date]))) + 1)

 

Ricardo

@saranee

 

Try this MEASURE for dynamic RANKING

 

RANK =
RANKX (
    FILTER ( ALLSELECTED ( Table1 ), Table1[Name] = SELECTEDVALUE ( Table1[Name] ) ),
    CALCULATE ( SELECTEDVALUE ( Table1[Date] ) ),
    ,
    DESC,
    DENSE
)

Regards
Zubair

Please try my custom visuals

Kudos on this solution

Anonymous
Not applicable

@Zubair_Muhammad Thanks for the solution, it worked seamlessly. 

@Zubair_Muhammad Thats the correct solution!!

Hi @rishikdutta1987,

Please mark the right solution as answer, so more people like you can find the solution easily.

Best Regards,
Angelia

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.