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
DaxPadawan
Helper III
Helper III

Ranking of values per month per group

The data is set up as follows, with the ranking that I'd like to see:

CategoryTypeScoreMonthRanking
A1100Jan 20211
A250Jan 20212
B375Jan 20211
B180Feb 20212
B390Feb 20211
C260Feb 20211
C355Mar 20211
C140Mar 20212

 

Basically, I wanted to rank the Types by the Scores, but within each Category and each Month.

I want to visualize it with a matrix, with the Category and Type as the rows and Month as the column. The ranking will be the values. 

 

Honestly, just really confused about whether or not this needs to be a calculated column or if this can be done as just a measure. I've been trying to use RANKX but no matter what I try, all the ranks are 1.

Thanks in advance y'all! 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@DaxPadawan , if you need static ranking you need a column, you need dynamic raking (usually on the measure) you need ti use measure

 

Column Rank = rankx(filter(Table, [Category] = earlier([Category])  && , [Month] = earlier([Month])), [Score],,desc, dense)

 

Meausre Rank

 

rankx(allselected(Table[Month]), calculate(sum(Table[Score])) ,,desc, dense)

 

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

View solution in original post

v-yanjiang-msft
Community Support
Community Support

Hi @DaxPadawan ,

According to your description, if you want a calculated column, @amitchandak's solution works fine. If you want a measure, here's my solution.

Measure =
RANKX (
    FILTER (
        ALL ( 'Table' ),
        [Category] = MAX ( [Category] )
            && [Month] = MAX ( [Month] )
    ),
    CALCULATE ( SUM ( [Score] ) ),
    ,
    DESC,
    DENSE
)

Get the result:

vkalyjmsft_0-1669000129176.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @DaxPadawan ,

According to your description, if you want a calculated column, @amitchandak's solution works fine. If you want a measure, here's my solution.

Measure =
RANKX (
    FILTER (
        ALL ( 'Table' ),
        [Category] = MAX ( [Category] )
            && [Month] = MAX ( [Month] )
    ),
    CALCULATE ( SUM ( [Score] ) ),
    ,
    DESC,
    DENSE
)

Get the result:

vkalyjmsft_0-1669000129176.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

amitchandak
Super User
Super User

@DaxPadawan , if you need static ranking you need a column, you need dynamic raking (usually on the measure) you need ti use measure

 

Column Rank = rankx(filter(Table, [Category] = earlier([Category])  && , [Month] = earlier([Month])), [Score],,desc, dense)

 

Meausre Rank

 

rankx(allselected(Table[Month]), calculate(sum(Table[Score])) ,,desc, dense)

 

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

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.