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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Rankx producing incorrect order

Hello,

 

I am trying below calculated column in my dataset to return a rank to limit my bar chart 

 

Custom Col Cancellation Ranks =
Var RankByCancellation=
RANKX(
All(MyPT_Cancellations),
CALCULATE(
COUNT(MyPT_Cancellations[No. of Clients]),
ALLEXCEPT(MyPT_Cancellations,MyPT_Cancellations[Cancellation reason])
),
,
DESC,
Dense
)
Return
IF(RankByCancellation<=9,RankByCancellation,10)

Now, this works but I doubt it does sorting counts by descending order 

PowerOn_DP_0-1616408333004.png

 

Can somebody please advise me urgently?

 
 
 
 
8 REPLIES 8
Anonymous
Not applicable

@Anonymous 

For the first question, replace the allexcept to following:

 

Custom Col Cancellation Ranks =
Var RankByCancellation=
RANKX(
All(MyPT_Cancellations[Cancellation reason]), // or use allselected in place of all
CALCULATE(
COUNT(MyPT_Cancellations[No. of Clients]),
Filter(Allselected(MyPT_Cancellations), MyPT_Cancellations[Cancellation reason]=MAX( MyPT_Cancellations[Cancellation reason])
),
,
DESC,
Dense
)
Return
IF(RankByCancellation<=9,RankByCancellation,10)

 


For more, please share a sample table or pbix(Not image),  that would make your current situation clear for us.

 


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , are you viewing it for Cancellation reason?

 

Then try like

Custom Col Cancellation Ranks =
Var RankByCancellation=
RANKX(
All(MyPT_Cancellations[Cancellation reason]), // or use allselected in place of all
CALCULATE(
COUNT(MyPT_Cancellations[No. of Clients]),
ALLEXCEPT(MyPT_Cancellations,MyPT_Cancellations[Cancellation reason])
),
,
DESC,
Dense
)
Return
IF(RankByCancellation<=9,RankByCancellation,10)

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak 

Sorry, i tried Allselected but doesnt changed anything. Let me share table format and output 

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@Anonymous , have tried with

All(MyPT_Cancellations[Cancellation reason])

 

Allselected(MyPT_Cancellations[Cancellation reason])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

Tried both format but still doesnt worked 

 

PowerOn_DP_0-1616410957203.png

 

 

Anonymous
Not applicable

@amitchandak 

Please guide how can remove dense rank and give separate rank if the value is same for the cancellation reason, I am doing top 19 + 20 (Other)

 

PowerOn_DP_0-1616411933542.png

 

So, in this case rather than having 12 rank for more than 1 record I want serial rank no matter if the values are same.

 

I tried removing dense but the result show 1 and then 20 for all

Anonymous
Not applicable

@amitchandak @Icey  Please help

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors