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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Shan_Drex12
Helper I
Helper I

Ranking question error

HI All,

 

I'm trying to do a ranking based on the highest accumulated days for detention.

 

I have the formula below, but the ranking seems to be out of order:

Rank = RANKX(ALL(Sheet1[Material Description]), CALCULATE(COUNT(Sheet1[# of Days in Detention])),,DESC)
 

rank.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Shan_Drex12 , Make sure # of Days in Detention is  COUNT(Sheet1[# of Days in Detention]). it should NOT be un/not summarized

 

Formula seems correct

 

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

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

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

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

HI @Shan_Drex12,

Can please share some dummy data with a similar data structure and expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

sanalytics
Super User
Super User

Hello @Shan_Drex12 

Below meaures can work for you

 

sanalytics_0-1609251601863.png

 

regards,

sanalytics

amitchandak
Super User
Super User

@Shan_Drex12 , Make sure # of Days in Detention is  COUNT(Sheet1[# of Days in Detention]). it should NOT be un/not summarized

 

Formula seems correct

 

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

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

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

Hi @amitchandak, if I don't use the 'don't summarize' table it messes up with the number of detention days I have. Inside of the query editer I did the difference between two dates. Also, for some reason I keep getting an error every time I try to share sample data, sorry I couldn't upload!

I used this formula:  inside of the power query to get the days detention by using this formula: Duration.Days(Duration.From([#"Today's Date"]-[Trailer Check In Time])) - 2

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.