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
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
Resolver I
Resolver I

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
Resolver I
Resolver I

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
Resolver I
Resolver I

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
Resolver I
Resolver I

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.