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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to rank a measure based on two column from different two table

Hello,

 

I am trying to do rank a measure based on two column. one column is from table1 and other is from table2. And there is one to many relation between the two table.  

I am using below dax- 

Ranking of employee per center per plan = CALCULATE([# of employee],FILTER(VALUES(Table1[center]),FILTER(VALUES(Table2[plan]),IF(RANKX(ALL(Table1[center],Table2[plan),[# of employee],,DESC,Dense)<=5,[# of employee],BLANK()))))
And getting the below error-->
alpha_123_0-1636713587351.png

Can anyone help me with the dax?

6 REPLIES 6
V-lianl-msft
Community Support
Community Support

See if this thread can help you:

https://community.powerbi.com/t5/Desktop/RANKX-measure-across-two-tables-not-working/td-p/468549 

If the problem still exists, please remove the sensitive data and provide a sample pbix and the results you expect, so as to make your scenario clearer.

amitchandak
Super User
Super User

@Anonymous , Try like examples

 

rank = RANKX(Summarize(ALL(Table),Table1[center],Table2[plan]), [# of employee], , DESC)

 

rank = RANKX(Summarize(allselected(Table),Table1[center],Table2[plan]), [# of employee], , DESC)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

after allselected, which table needs to be used?

Anonymous
Not applicable

Hi @amitchandak 
I have used the formula that you have suggested.
I have used center from one table & plan from another table.

 

But getting the below error-

alpha_123_0-1636991390799.png
Can you look into it?

 

 

@Anonymous , Please share the formula. Check Summarize, should have table that is getting closed properly 

example

summarize(allselected(Table) , Table[Col], Table2[Col])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak ,
Basically, 

I have below chart

alpha_123_0-1636994269602.png

In this gragh I have taken count of emp id and group by center & plan.

Center is from one table and Plan is from another table. Count of employee id is from the table from where i have taken Plan.
So my requirement is only to showTop 5 employee count per Center per plan.

I have mapped center table with plan table with employee id.

alpha_123_1-1636994539402.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors