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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Syndicate_Admin
Administrator
Administrator

Conditional Ranking

Hello everyone!

I have a situation with the RANKX function, I need to condition a field so that the top 5 positions in the list are >- than 6, the formula I currently use is RANKX(ALL('Customer'[Nombre_Cliente]); sum('Customer'[promedio_viaje] >-6))

I look for this feature to return a top 5 with customers with travel averages of 6 (averages are calculated in the table).

This measure does not present me with any data, I would like to know if there are alternatives.

Thanks in advance.

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @Syndicate_Admin 

According to your description, you want to get the top 5 positions in the list are more than 6, you can try my steps:

This is the test data I created based on your DAX formula:

v-robertq-msft_0-1612863503385.png

 

  1. I created a calculated column:

 

Rank =

var _rank=

RANKX(

    FILTER(ALL(Customer),[promedio_viaje]>=6),

    [promedio_viaje],, DESC,Dense)

return

IF([promedio_viaje]<6,BLANK(),_rank)

 

The calculated column displayed like this in the table:

v-robertq-msft_1-1612863503388.png

 

  1. I created a table chart and place the columns in the table, then I apply a filter on this table chart to filter the data in this chart to top5 of rank, like this:

v-robertq-msft_2-1612863503400.png

 

And you can get what you want.

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, @Syndicate_Admin 

According to your description, you want to get the top 5 positions in the list are more than 6, you can try my steps:

This is the test data I created based on your DAX formula:

v-robertq-msft_0-1612863503385.png

 

  1. I created a calculated column:

 

Rank =

var _rank=

RANKX(

    FILTER(ALL(Customer),[promedio_viaje]>=6),

    [promedio_viaje],, DESC,Dense)

return

IF([promedio_viaje]<6,BLANK(),_rank)

 

The calculated column displayed like this in the table:

v-robertq-msft_1-1612863503388.png

 

  1. I created a table chart and place the columns in the table, then I apply a filter on this table chart to filter the data in this chart to top5 of rank, like this:

v-robertq-msft_2-1612863503400.png

 

And you can get what you want.

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PC2790
Community Champion
Community Champion

Hi,

 

There might be a better way to do it, however try the below appraoch:

Create a DAX table with the below formula:

Top5 = TOPN(5,TOPN
(5,
SUMMARIZE(
TableName
,TableName[Column],"ColumnName", Average(TableName[Column])
),"ColumnName",DESC))

 I hope this works

vanessafvg
Super User
Super User

this article is quite useful to understand your options.  there are several ways you can do this

 

https://www.sqlbi.com/articles/filtering-the-top-3-products-for-each-category-in-power-bi/





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.