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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors