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
cjcj
Helper I
Helper I

RankX with filter

Hi I am running into a wall trying to figure out how to have Rankx to work with filters.

Rankx is currently working correctly on the full table (Table 1 below) using:

Rank = RANKX(
Summarize(ALLSELECTED('CustomerTbl'), 'CustomerTbl'[CustomerName]),
[Sales]
,,DESC
)

However, when I use the Customer filter I am getting strange rank results (see Table 2 below).  I am using DQ so cannot provide dummy data, but any ideas, suggesions would be appreciated.

 

cjcj_0-1672783986800.png

 

 

5 REPLIES 5
aj1973
Community Champion
Community Champion

Hi @cjcj 
this can help you out

https://www.youtube.com/watch?v=pM_8zsPidRk&t=731s

https://www.youtube.com/watch?v=aMbtfBzTtBc&t=780s

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

hi @aj1973 , inscope did not yield any different resuts and unfortunately I cannot leverage video 2 for adding columns since I am on Direct Query.

Hi @cjcj ,

 

From the test in myside, I think you issue should be caused by [Sales] measure or your data model.

My Sample:

RicoZhou_0-1672818056703.png

Result is as below.

RicoZhou_1-1672818078889.png

RicoZhou_2-1672818118727.png

In my sample I use sum to get sales value without any filter. Please check the calculation logic of your measure.

If this still couldn't help you solve your issue, please show me more details about your data model and your calculation logic.

 

Best Regards,
Rico Zhou

 

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

 

 

 

@cjcj , if you do want rank to change then you can use all , try  if that can help

 

Rank = RANKX(
Summarize(ALL('CustomerTbl'), 'CustomerTbl'[CustomerName]),
[Sales]
,,DESC
)

thx for the suggestion @amitchandak I tried Summarize(All..and the ranking is correct when I apply to Table 1(with all customers), but not correct under Table 2 with customer filter applied to just 1 customer. Wondering if the problem is occuring due to customer filter being a dim table? 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.