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
SinaA
Frequent Visitor

Develop a Ranking based On filtered Data (Static & Dynamic)

Hi all,

 

I created a measure that will rank universities based on the total score they obtained from multiple projects. This ranking is dynamic based on the applied filters such as Year and Journal.
Suppose a user filters for a specific university using the slicer. In that case, it will impact the rank as the rank is calculated based on the current filter context, which includes the university selection. However, I want to show the rank of a selected university against all universities (regardless of any other applied filters). For example, if UNI X ranks based on selected years and journals are 32, I want this rank to show up after users filter for UNI X and see the number 32. My issue is once I filter for the particular university to see its rank, the rank will be changed to another number which is not accurate. Here is my DAX code:

 

NewRank = RANKX ( ALL('SinaA'[University]), CALCULATE (SUM('SinaA'[Score]), ALLEXCEPT(SinaA, SinaA[University],SinaA[Journal], SinaA[Year])), , DESC, Dense )

 

Sample Data:

https://wichitaedu-my.sharepoint.com/:x:/g/personal/z829w854_wichita_edu/EbUX4mTGpcFCpsm-ROXjuRkBhgr...

 

Thanks!

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @SinaA ,

Please update the formula of measure [NewRank] as below and check if it can return the expected result...

NewRank =
RANKX (
    ALLSELECTED ( 'SinaA'[University] ),
    CALCULATE (
        SUM ( 'SinaA'[Score] ),
        ALLEXCEPT ( SinaA, SinaA[University], SinaA[Journal], SinaA[Year] )
    ),
    ,
    DESC,
    DENSE
)

In addition, you can refer the following links to try to solve the problem.

How to use RANKX in DAX (Part 1 of 3 - Calculated Columns) - RADACAD

powerbi - RANKX does not give the correct result - Stack Overflow

Solved: Issues with RANKX - Microsoft Fabric Community

If the above one can't help you, could you please provide more special examples to explain your expected result base on your sample data file?It would be helpful to find out the solution. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

Hi @SinaA ,

Please update the formula of measure [NewRank] as below and check if it can return the expected result...

NewRank =
RANKX (
    ALLSELECTED ( 'SinaA'[University] ),
    CALCULATE (
        SUM ( 'SinaA'[Score] ),
        ALLEXCEPT ( SinaA, SinaA[University], SinaA[Journal], SinaA[Year] )
    ),
    ,
    DESC,
    DENSE
)

In addition, you can refer the following links to try to solve the problem.

How to use RANKX in DAX (Part 1 of 3 - Calculated Columns) - RADACAD

powerbi - RANKX does not give the correct result - Stack Overflow

Solved: Issues with RANKX - Microsoft Fabric Community

If the above one can't help you, could you please provide more special examples to explain your expected result base on your sample data file?It would be helpful to find out the solution. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.