Reply
yasbos
Resolver II
Resolver II
Partially syndicated - Outbound

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
Super User
Super User

Syndicated - Outbound

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)





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

Proud to be a Super User!





View solution in original post

2 REPLIES 2
ExcelMonke
Super User
Super User

Syndicated - Outbound

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)





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

Proud to be a Super User!





Syndicated - Outbound

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

 

 

avatar user

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)
Users online (99)