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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.