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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

RANX with two tables

Hi there, 

My first post here, so I'm nervous 🙂

I have two tables: forum_1.JPG

User IDs have a relationship in the model. 

I created a simple visual using two measures: 

1. Total values: SUM('FACT TABLE'[values])

2. Rank: 

RANKX
(
    ALLSELECTED('FACT TABLE'[user_id]),
    [Total values],
    ,
    DESC,
    Dense
)
and it works well: 
forum_2.JPG

However, when I add username to the visual, the rank gets corrupted: 

forum_3.JPG

How could I get to this: forum_4.JPG

What am I doing wrong? 

 

Many thanks!

 

 

4 REPLIES 4
mussaenda
Super User
Super User

Try putting the usrname on your fact table.

and use that username to your visual.

Did it rank correctly?

Anonymous
Not applicable

@mussaenda thanks for your prompt reply. Yes, I could do it but I'm not 100% sure if this is the right approach as user name is not the only one reference data being used in this case. For example, I would like to add "country" to the visual and I'd have to add this column to the fact table as well. 

This would, in effect, turn my fact table into fact+ref table which is not super elegant. I mean I could but this would turn my fact tables into unmanagable monsters 🙂 

Okay, I get you.

For sure someone else here will share ideas.

Anonymous
Not applicable

So I tested it by adding a new column in the fact table like this: 

User name = RELATED('REF Table'[user name])

but to no avail, the rank gets corrupted. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.