Forum Discussion
nish18_1990
Helper III
9 months agoOptimize the dax query for TOP N parameter
Hi , I want to have ranking based on TOPN parameter selection . If i select 3 in Top N RES Parameter then it should show be top 3 Responsible Legal Entity based on measure [#OnlyOpen]. The below cal...
- Anonymous9 months ago
Hi nish18_1990 ,
Please try below measures.
Measure 1: Top N Responsible (Boolean filter).
Top N RES Flag =
VAR N =
SELECTEDVALUE ( 'Top N RES Parameter'[Top N RES Parameter Value], 0 )
VAR TopNTable =
TOPN (
N,
ALL ( 'My_Main_Table'[Resp Risk Unit Level 2 Name] ),
[#OnlyOpen], DESC
)
RETURN
IF (
MAX ( 'My_Main_Table'[Resp Risk Unit Level 2 Name] ) IN TopNTable,
1,
0
)Measure 2: Final Result
Top N RES =
IF ( [Top N RES Flag] = 1, [#OnlyOpen] )If my response as resolved your issue please mark it as solution and give kudos.
Thanks,
Dinesh
parry2k
Super User
9 months agonish18_1990 try this:
Top N =
VAR __Top = 5
RETURN
CALCULATE (
SUM ( TopTest[Only Open ] ),
KEEPFILTERS (
TOPN (
__Top,
ALLSELECTED ( TopTest ),
CALCULATE ( SUM ( TopTest[Only Open ] ) )
)
)
)nish18_1990
Helper III
9 months agoHi ,
I need dynamic parameter selection for Top N . Like if i select 3 then show me 3 res , if i select 5 then show me 5 res