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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Vladracs
Helper I
Helper I

Simple Ranking

Hi Experts, 

Im a newbie here, so I tried some online article, but failed 😕

I am looking to create a ranking for each year, per Customer based on Sale Size for each Sale Type:

 

 

Sample Table and Ranking ( I repeat every year the same, but of course they could have been different 🙂 )

 

 

 

DateCustomerSale TypeSale SizeRanking
202211103
202221151
202231132
202212203
202222222
202232251
202213361
202223343
202233352
202111103
202121151
202131132
202112203
202122222
202132251
202113361
202123343
202133352
202011103
202021151
202031132
202012203
202022222
202032251
202013361
202023343
202033352
1 ACCEPTED SOLUTION

this works for a Table visual:

Table Rank = if(ISINSCOPE('Table'[Date]),RANKX(ALLSELECTED('Table'[Date],'Table'[Customer],'Table'[Sale Type]),calculate(sum('Table'[Sale Size])),,DESC,Dense))

 

This works for a matrix visual

Rank =
VAR yearrank = RANKX(ALLSELECTED('Table'[Date]),Calculate(SUM('Table'[Sale Size])),,DESC,Dense)
VAR custrank = RANKX(ALLSELECTED('Table'[Customer]),Calculate(SUM('Table'[Sale Size])),,DESC,Dense)
VAR typerank = RANKX(ALLSELECTED('Table'[Sale Type]),Calculate(SUM('Table'[Sale Size])),,DESC,Dense)
RETURN
SWITCH(TRUE(),ISINSCOPE('Table'[Sale Type]),typerank,ISINSCOPE('Table'[Customer]),custrank,
ISINSCOPE('Table'[Date]),yearrank)

View solution in original post

7 REPLIES 7
Padycosmos
Solution Sage
Solution Sage

Almost! Actually a better vid from here would be: https://www.youtube.com/watch?v=y2FFjfRD-Bo

however, the ranking is not really working. 

Screenshot 2023-02-26 at 19.59.45.png

 Not sure if this is because I am trying to filter on the date as well...
Total Size = SUM(Table[Size])
Ranking = RANKX (ALLSELECTED(Table[Customer]),[Total Size],,DESC,Dense)

this works for a Table visual:

Table Rank = if(ISINSCOPE('Table'[Date]),RANKX(ALLSELECTED('Table'[Date],'Table'[Customer],'Table'[Sale Type]),calculate(sum('Table'[Sale Size])),,DESC,Dense))

 

This works for a matrix visual

Rank =
VAR yearrank = RANKX(ALLSELECTED('Table'[Date]),Calculate(SUM('Table'[Sale Size])),,DESC,Dense)
VAR custrank = RANKX(ALLSELECTED('Table'[Customer]),Calculate(SUM('Table'[Sale Size])),,DESC,Dense)
VAR typerank = RANKX(ALLSELECTED('Table'[Sale Type]),Calculate(SUM('Table'[Sale Size])),,DESC,Dense)
RETURN
SWITCH(TRUE(),ISINSCOPE('Table'[Sale Type]),typerank,ISINSCOPE('Table'[Customer]),custrank,
ISINSCOPE('Table'[Date]),yearrank)

Thank you very much!

you need to use an explicit measure. 

lbendlin_0-1677440247197.png

 

 

see attached.

 

Obligatory SQLBI article: Use of RANKX in Power BI measures - SQLBI

lbendlin
Super User
Super User

I don't see Sales_Type.  Please provide sample data that matches your description. Please indicate expected outcome.

Sorry for the confusing post, Ive re-edit, which should make it more clear.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors