Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

Top N slicer

TopN Borrower = 
VAR SelectedTop = SELECTEDVALUE('TopN'[TopN])
RETURN
SWITCH(TRUE(),
    SelectedTop = 0, sum(power_bi_source_final[Unrealized Value (USD)]),
    RANKX ( 
            ALLSELECTED(  'power_bi_source_final'[Risk - COUNTERPARTY / ASSET NAME] ), 
            sum('power_bi_source_final'[Unrealized Value (USD)])
                )
                  <= SelectedTop,
        sum('power_bi_source_final'[Unrealized Value (USD)])
)

 

Here is the script I have for Top N slicer. By changing TopN value, i hope to return 'Risk  - Counterparty/Asset Name based on the unrealized value. I dragged this TopN borrower into a table and change the slicer of TopN. However the rows don't change accordinly. 

 

May I know what might be the issues? 

 

Thank you. 

2 Replies

  • Anonymous , You Can use TOPN or windows function

     

    example

     

    Sumx(keepfilters(topn(selectedvalue(Top[Value]) , allselected('Fact Jobs'[AvgDuration]) ,_roll18, desc)),[Duration Measure])

     

     

    Learn Power BI: Dynamic TOPN using TOPN/Window and Numeric parameter: https://youtu.be/vm2mdEioQPQ

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

    If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

    How to Get Your Question Answered Quickly 

    Regards,

    Xiaoxin Sheng