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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
yasbos
Resolver I
Resolver I

Ranking a table variable

Hi. I have a table variable created using calculatetable in a dax measure. I need to rank this table based on column [Value]. I can do that with Rankx. However, it seemst that Rankx doesn't take the decimal points into consideration because I have two values (6.5 and 6.3) in the table, but it seems to give both of them the same rank. I was told that I should use Rank function to resolve this issue. However, it seems that Rank doesn't work with calculated table variables in a measure. Is there a way to make Rankx consider two decimal places? If not, will Rank work? Will it work on a table variable? Thanks.

1 ACCEPTED SOLUTION
ExcelMonke
Responsive Resident
Responsive Resident

Consider wrapping your measure results in a round function, with multiple decimal points (e.g. ROUND([Value],3), and RANKX from there. This was you can determine if it truly is a rounding issue (i.e. Rankx not picking up the decimals)

View solution in original post

2 REPLIES 2
ExcelMonke
Responsive Resident
Responsive Resident

Consider wrapping your measure results in a round function, with multiple decimal points (e.g. ROUND([Value],3), and RANKX from there. This was you can determine if it truly is a rounding issue (i.e. Rankx not picking up the decimals)

Thanks, @ExcelMonke .  You are right. I mistakenly thought that it truncated the decimals. When I dug deeper, I found that both numbers were identical, so the ranks were also identical. The problem now is that i'm later selecting from that table that has several rows with two of them having the same rank. The problem is in the next step where i select the top 5 values based on their ranks. So, I go like "give me the value where rank is 1; give me the value where rank is 2, ... where rank is 5." If the table has the below values, then I will be getting A, B, C, D and F as items with ranks 1, 2, 3, 4, 5 -- when I really should be getting E instead of F because E has a value of 7, but E is 6. I mean, it makes a difference in the context of the report.

IDValueRank
A101
B92
C83
D74
E74
F65

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.