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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
JaynaC
New Member

How to create ranking using Matrix table and multi select months

Hi Power BI Community,

I have a question regarding how to create a dynamic ranking using a matrix table that allows multi select month year.
At the moment the ranking works for single select month year but when I select additional month year the ranking doesn't work as it should.

I'm currently using the following

Rank =

RANKX (
FILTER ( ALLSELECTED ( 'CrossPurchase_Category' ), 'CrossPurchase_Category'[Category] = MAX ( 'CrossPurchase_Category'[Category] ) ),
CALCULATE ( SUM ( 'CrossPurchase_Category'[baskets] ) ),)

which gives me this when only Nov 23 is selected

JaynaC_0-1718884284517.png


But if I select Dec23 as well then the rank is no longer 1-14

JaynaC_1-1718884341860.png

 

Any idea how to solve this?

 

 







1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from @amitchandak , please allow me to provide another insight:

 

Hi @JaynaC ,

 

Maybe you can try formula like below, when i choose muti month in slicer, it works well.

 

 

Total Baskets = SUM(CrossPurchase_Category[Baskets])
Dynamic Rank =
RANKX ( ALLSELECTED ( slicer_[Category] ), [Total Baskets],, ASC, DENSE )

 

 

vkongfanfmsft_0-1718960012107.png

vkongfanfmsft_1-1718960023115.png

Best Regards,
Adamk Kong

 

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

3 REPLIES 3
Anonymous
Not applicable

Thanks for the reply from @amitchandak , please allow me to provide another insight:

 

Hi @JaynaC ,

 

Maybe you can try formula like below, when i choose muti month in slicer, it works well.

 

 

Total Baskets = SUM(CrossPurchase_Category[Baskets])
Dynamic Rank =
RANKX ( ALLSELECTED ( slicer_[Category] ), [Total Baskets],, ASC, DENSE )

 

 

vkongfanfmsft_0-1718960012107.png

vkongfanfmsft_1-1718960023115.png

Best Regards,
Adamk Kong

 

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

JaynaC
New Member

@amitchandak 
Thanks for that... It's almost there I used the M1 and new rank measures however the ranking is going horizontally instead of vertically.. do you know how I could change that?

JaynaC_0-1718885584714.png

 

amitchandak
Super User
Super User

@JaynaC , Try like

 

Rank =

RANKX (
FILTER ( ALLSELECTED ( 'CrossPurchase_Category'[Category] ), 'CrossPurchase_Category'[Category] = MAX ( 'CrossPurchase_Category'[Category] ) ),
CALCULATE ( SUM ( 'CrossPurchase_Category'[baskets] ) ))


Or create a measure

 

M1= CALCULATE ( SUM ( 'CrossPurchase_Category'[baskets] ), FILTER ( ALLSELECTED ( 'CrossPurchase_Category'[Category] ), 'CrossPurchase_Category'[Category] = MAX ( 'CrossPurchase_Category'[Category] ) ) )

 

Try new Rank Function

Rank(dense, ALLSELECTED ( 'CrossPurchase_Category'[Category] ) orderby(M1,desc))

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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