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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
KarolDmo
Regular Visitor

Rankx with switch and field parameters - performance issue

Hello ! 

I would like to have dynamic top 5 KDU on visuals - taking into consideration current filtering and also Measure selection (using field parameters and switch function). 

It result with bad performance and usually error with not sufficent memory. The Dax which I have tried looks like this:

 

KDU RANK =
var KDU = ALLSELECTED(Data[KDU])

RETURN
SWITCH(TRUE(),
SELECTEDVALUE('Measure Selection'[Measure Selection Order])= 0,RANKX(KDU,[Total vs PC]) ,
SELECTEDVALUE('Measure Selection'[Measure Selection Order])= 1,RANKX(KDU,[Std Cost vs PC]),
SELECTEDVALUE('Measure Selection'[Measure Selection Order])= 2,RANKX(KDU,[Std vs PC]) ,
SELECTEDVALUE('Measure Selection'[Measure Selection Order])= 3,RANKX(KDU,[Std Costs 3rd vs PC]),
SELECTEDVALUE('Measure Selection'[Measure Selection Order])= 4,RANKX(KDU,[company Purchases vs PC]) ,
SELECTEDVALUE('Measure Selection'[Measure Selection Order])= 5,RANKX(KDU,[Other vs PC]),
SELECTEDVALUE('Measure Selection'[Measure Selection Order])= 6,RANKX(KDU,[Total Volume vs PC]) ,
SELECTEDVALUE('Measure Selection'[Measure Selection Order])= 7,RANKX(KDU,[Total net]),
SELECTEDVALUE('Measure Selection'[Measure Selection Order])= 8,RANKX(KDU,[Std Cost net]),
SELECTEDVALUE('Measure Selection'[Measure Selection Order])= 9,RANKX(KDU,[Std net]),
SELECTEDVALUE('Measure Selection'[Measure Selection Order])= 10,RANKX(KDU,[Std Costs 3rd net]) ,
SELECTEDVALUE('Measure Selection'[Measure Selection Order])= 11,RANKX(KDU,[company Purchases net]),
SELECTEDVALUE('Measure Selection'[Measure Selection Order])= 12,RANKX(KDU,[Other net])
)

 

Any ideas how to use rankx with good performance with dynamic measure selection ?

 

1 REPLY 1
amitchandak
Super User
Super User

@KarolDmo , Try like

 

KDU RANK =
var KDU = ALLSELECTED(Data[KDU])
var _sel = SELECTEDVALUE('Measure Selection'[Measure Selection Order])
var _mes = SWITCH(_sel
,
0, [Total vs PC],
1, [Std Cost vs PC],
2, [Std vs PC],
3, [Std Costs 3rd vs PC],
4, [Company Purchases vs PC],
5, [Other vs PC],
6, [Total Volume vs PC],
7, [Total net],
8, [Std Cost net],
9, [Std net],
10, [Std Costs 3rd net],
11, [Company Purchases net],
12, [Other net]
)


RETURN
RANKX(KDU,_mes)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.