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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
hood2media
Resolver I
Resolver I

dax | ranking by a measure to a monthly list

hi,

apprec any help to create a ranking no (1,2,3,4.....) to the table below:
Screenshot 2024-04-29 165434.png

the month is taken from the calendar table while the 'total crime' measure is simply calculated as follows:

COUNTROWS( CrimeData )
 
i tried using following dax formula but it gives my just '1' for all months
 
RANKX(
ALL( 'Calendar'[Month] ),
[Total Crime], ,
DESC,
Dense)
 
note:
i also intend to do similar table to rank the 'total crime' measure by day of week. 
tks & krgds, -nik
3 ACCEPTED SOLUTIONS
v-yiruan-msft
Community Support
Community Support

@manvishah17 Thanks for your contribution on this thread.

Hi @hood2media,

I have created a sample PBIX file and applied the same formula as yours to the visual. However, it can return the expected result.vyiruanmsft_0-1714454240454.pngI am uncertain about the cause of this issue. Could you kindly provide some sample data from the ‘CrimeData’ table in Text format (excluding any sensitive information)? This would greatly assist in identifying the problem and finding a solution. For instructions on how to share the required information, please refer to the following link: 

How to provide sample data in the Power BI Forum

Best Regards 

Community Support Team _ Rena
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

manvishah17
Responsive Resident
Responsive Resident

See I also created sample pbix file , and also tried to implement weekday wise rank. 
Hope this help. 
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.Screenshot 2024-04-30 132017.png

 

View solution in original post

dear @manvishah17 & @v-yiruan-msft,

 

pursuant to the earlier responses, i hv found out tht the reason for the inability to get the ranking to b shown properly was bcoz of the sorting order for the month (sorted by monthno) & day name (by dayno) - all of which were initially created in the calendar table thru power query.

 

hvg flwed the solution fm the flwg webpage, i hv managed to resolve the issue:

Ranking by Month & Year not working with RANKX - DAX / DAX Calculations - Enterprise DNA Forum

 

i hv also appended blw, the calendar table + the correct report:

 

Screenshot 2024-05-02 094153.png

 ---

Screenshot 2024-05-02 094356.png

---

many tks again to both of u fr yr suggestions. they r most apprec.

krgds, -nik  

View solution in original post

7 REPLIES 7
manvishah17
Responsive Resident
Responsive Resident

See I also created sample pbix file , and also tried to implement weekday wise rank. 
Hope this help. 
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.Screenshot 2024-04-30 132017.png

 

tks @manvishah17 & @v-yiruan-msft .

as i'm still on the road / travelling now, pls allow me some time to chk/respond on this later.

krgds, -nik

dear @manvishah17 & @v-yiruan-msft,

 

pursuant to the earlier responses, i hv found out tht the reason for the inability to get the ranking to b shown properly was bcoz of the sorting order for the month (sorted by monthno) & day name (by dayno) - all of which were initially created in the calendar table thru power query.

 

hvg flwed the solution fm the flwg webpage, i hv managed to resolve the issue:

Ranking by Month & Year not working with RANKX - DAX / DAX Calculations - Enterprise DNA Forum

 

i hv also appended blw, the calendar table + the correct report:

 

Screenshot 2024-05-02 094153.png

 ---

Screenshot 2024-05-02 094356.png

---

many tks again to both of u fr yr suggestions. they r most apprec.

krgds, -nik  

v-yiruan-msft
Community Support
Community Support

@manvishah17 Thanks for your contribution on this thread.

Hi @hood2media,

I have created a sample PBIX file and applied the same formula as yours to the visual. However, it can return the expected result.vyiruanmsft_0-1714454240454.pngI am uncertain about the cause of this issue. Could you kindly provide some sample data from the ‘CrimeData’ table in Text format (excluding any sensitive information)? This would greatly assist in identifying the problem and finding a solution. For instructions on how to share the required information, please refer to the following link: 

How to provide sample data in the Power BI Forum

Best Regards 

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
manvishah17
Responsive Resident
Responsive Resident

Yes 'sheet 1' is my fact table having all crimes number and dates of them occuring . 
Can you tell me more about your error.

manvishah17
Responsive Resident
Responsive Resident

Use this measure for your desired output.

Rank = RANKX(
    ALL(Sheet1),
    [TotalCrime],
    ,
    DESC
)Screenshot 2024-04-29 151733.png

 

hi @manvishah17 ,
is 'sheet1' your fact_table which in my case is 'CrimeData'?
i hv tried that for my 'CrimeData' table but it stil doesn't give the desired result.
krgds, -nik

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.