cancel
Showing results for 
Search instead for 
Did you mean: 
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.

View solution in original post

PC2790
Impactful Individual
Impactful Individual

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

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/





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

Proud to be a Super User!




Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

March Update

Check it Out!

Click here to read more about the March 2021 Updates!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

secondImage

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.