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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Ranking in Matrix Visual and Datewise

Hi Friends,

 

I am facing one of the peculiar situtation, i have a matrix visual like the below.

Infijeevan_0-1645006482615.png

Note: In the image the formula i have used showing rank 5 for all the regions and for all the dates but i need to see actual raking here.

 

I am using below fields for matrix visual

Infijeevan_1-1645006531559.png

I need to arrive ranking for Region (Row) for different dates (column) and also when i expand the matrix visual from Region to State Province i should see the ranking for State or Province within that region.
When i expand (Region to State or Province) i think i am seeing correct ranking values but at the Region level the ranking is showing as 5 only.

Infijeevan_2-1645006920509.png

The DAX formul i have used here is below.

Sales Ranking =
IF (
ISINSCOPE(Orders[State or Province]),
RANKX(
CALCULATETABLE(
VALUES(Orders[State or Province]),
ALLSELECTED(Orders[State or Province]) ),
 
[Total Sales],,DESC,dense
),
IF(
ISINSCOPE(Orders[Region]),
VAR CustomerRanking = [Total Sales]
RETURN
CALCULATE(
RANKX(
VALUES(Orders[Region]),
[Total Sales],
CustomerRanking
,DESC,dense
),
ALLSELECTED()
)
)
)

 

Can someone help me on this here.

 

@amitchandak @Greg_Deckler @diex @aj1973 @BA_Pete @Jihwan_Kim 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @Anonymous,

I think you need to add if statement to check the current hierarchy level and write different rank formulas for the different level ranking:

Clever Hierarchy Handling in DAX - SQLBI

DAX – Ranking with Hierarchy Drill-Down – Azure Data Ninjago & dqops

Regards,

Xiaoxin Sheng

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , change the region if like

IF(
ISINSCOPE(Orders[Region]),
VAR CustomerRanking = [Total Sales]
RETURN
CALCULATE(
RANKX(
ALLSELECTED(Orders[Region]),
[Total Sales], ,
,DESC,dense
)
)
)

 

This means each region will get rank for each date

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
Anonymous
Not applicable

Hi Amit,

 

Thanks for the revert.

 

Your DAX is giving me correct result at Region Level.

Infijeevan_0-1645009753326.png

But When i expand to State or Province it is giving me Rank 1 for all the dates.

Infijeevan_1-1645009816427.png

It has to give me Raning for State or Province within that Region.

Anonymous
Not applicable

HI @Anonymous,

I think you need to add if statement to check the current hierarchy level and write different rank formulas for the different level ranking:

Clever Hierarchy Handling in DAX - SQLBI

DAX – Ranking with Hierarchy Drill-Down – Azure Data Ninjago & dqops

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.