Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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 ?
@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)
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
20 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
26 | |
10 | |
10 | |
9 | |
6 |