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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
bssienes
Regular Visitor

RANX in ascending order

Hi All,

 

In my table I have companyName and featureName columns. I want to count rows in the table and rank based on featureName. This worked for me when I did ranking in descending order. Using the following code:

FeatureRank = RANKX(
        ALL('Features'[FeatureName]),
        CALCULATE(COUNTROWS('Features')),
        ,
        DESC
    )

However, If I do this in an ascending order, the output is not quiet what I expect in one scenario.
FeatureRank = RANKX(
        ALL('Features'[FeatureName]),
        CALCULATE(COUNTROWS('Features')),
        ,
        ASC
    )

For one of the companies I had all the features used (there are 11 features in total) so, it return the rank correctly in ascending order based on featureName. The ranks were changing from 1,2,3,...11 based on the number of times the featureNames occured.

However for another company I had only 3 featureNames. The rank that I received for these 3 features were 9,10 and 11. 
How do I get ranks 1,2,3 for the second company?

Note that I could have another company with different number of features used. How can I consistently rank the least used feature as 1 for each company?
1 REPLY 1
wdx223_Daniel
Super User
Super User

FeatureRank = RANKX(
        FILTER(ALL('Features'[FeatureName]),CALCULATE(COUNTROWS('Features'))),
        CALCULATE(COUNTROWS('Features')),
        ,
        ASC
    )

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.