Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
14 | |
13 | |
11 | |
9 | |
9 |