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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
PhilSmith
Helper III
Helper III

Ranking fails when I add a reference table

No filters, nothing extraneous. Within a single table, CSD, I have a ranking measure that works just fine, grouped by project_id.

Rank (by Actual) =
VAR ThisActual = [Actual]
RETURN
IF(ISBLANK(ThisActual),BLANK(),RANKX(ALLSELECTED( CSD[Project_id] ),[Actual],,DESC,Dense))

However, when I reference project_id in Project, which is related on project_id, all of the rankings go to 1.  It is a simple one to many relationship on project_id.

In the linked model I have three tables visuals. The second and third should be identical. The first should give me rankings based on ProjectName.

Can someone explain what is going on?

Phil

RankTest.pbix

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @PhilSmith 

That’s expected behavior. The measure is only modifying the filter context of the CSD[Project_id] column. Once additional columns are added to the visual, the filter context is split across each distinct combination of those columns. As a result, the calculation is evaluated within those more granular contexts, which changes the result. Instead apply ALLSELECTED to the Project table so whatever columns is used from this table respect the ranking. Also, don't use CSD[Project_id] in the visual.

Licensee Rank (by Actual) = 
VAR ThisActual = [Actual]
RETURN
    IF (
        ISBLANK ( ThisActual ),
        BLANK (),
        RANKX ( ALLSELECTED ( Project ), [Actual],, DESC, DENSE )
    )

danextian_0-1770967250065.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

4 REPLIES 4
v-nmadadi-msft
Community Support
Community Support

Hi @PhilSmith 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.


Thank you.

danextian
Super User
Super User

Hi @PhilSmith 

That’s expected behavior. The measure is only modifying the filter context of the CSD[Project_id] column. Once additional columns are added to the visual, the filter context is split across each distinct combination of those columns. As a result, the calculation is evaluated within those more granular contexts, which changes the result. Instead apply ALLSELECTED to the Project table so whatever columns is used from this table respect the ranking. Also, don't use CSD[Project_id] in the visual.

Licensee Rank (by Actual) = 
VAR ThisActual = [Actual]
RETURN
    IF (
        ISBLANK ( ThisActual ),
        BLANK (),
        RANKX ( ALLSELECTED ( Project ), [Actual],, DESC, DENSE )
    )

danextian_0-1770967250065.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ashish_Mathur
Super User
Super User

Hi,

Revise the measure to

Licensee Rank (by Actual) = 
VAR ThisActual = [Actual]
RETURN
IF(ISBLANK(ThisActual),
    BLANK(),
    RANKX(ALLSELECTED(Project[project_id] ),[Actual],,DESC,Dense))

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ribisht17
Super User
Super User

hi @PhilSmith 

In the Project table, each row corresponds to a single project. That means when the measure evaluates, the context only contains one Project_ID. Ranking across a single value, always returns 1—because there’s nothing else to compare against in that context.

 

Try This,

 

RANKX(
ALLSELECTED(Project[Project_id]),
[Actual],
,
DESC,
Dense
)

 

I can see the correct answer now

 

Regards,

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.