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
Anonymous
Not applicable

Rankx on value within different time periods

I have a situation in which I am ranking various metrics for 15 different stores. In addtion I also have three different reporting dates (the last day of each quarter), that are being chosen via a slicer.

I have created a calculated ranking for all stores for each metric.

The formula I am using is: RANKX(ALLEXCEPT(TABLE, REPORTING PERIOD), CALCULATE(SUM(METRIC)))

 

This formula is working great and is correct. However, there are several metrics that need to be ascending instead descending because a smaller value is actually better (If that particular store has the smallest value, then it would rank 1). When I change the formula to asc at the end, it then proceeds to rank from 31 -45 instead of 1-15, regardless of whichever time period I choose in the slicer.

 

Does anybody know how to correct this formula so that ascending will work? Thanks in Advance. 

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Anonymous 

Can you try the following pattern?

RANKX (
    CALCULATETABLE ( ALLSELECTED ( table ), VALUES ( table[REPORTING PERIOD] ) ),
    CALCULATE ( SUM ( Table[METRIC] ) )
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

This worked. Thank You, Kindly.

Fowmy
Super User
Super User

@Anonymous 

Can you try the following pattern?

RANKX (
    CALCULATETABLE ( ALLSELECTED ( table ), VALUES ( table[REPORTING PERIOD] ) ),
    CALCULATE ( SUM ( Table[METRIC] ) )
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.