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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
shubh25
Helper I
Helper I

Top N Slicer in a matrix?

Hi,

I need this Top N filter/slicer in the form of a slicer in visual so that we are able to see top 5,10 based on the value of balance column and in this matrix form. I am able to do this using RankX in table form but all goes haywire in matrix form.

Is there a solution?

top n.PNG
Attaching the link to sample data.

https://www.dropbox.com/sh/u3bmhm9gosvl2te/AACcbXbs-8jWdh_CMgnz5MTSa?dl=0

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @shubh25 

 

Please see the attached solution, I've added an extra table "Top N selector" for filtering and adjusted Rank Balance Measure and Visual filter to reflect the changes.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

 

View solution in original post

7 REPLIES 7
Mariusz
Community Champion
Community Champion

Hi @shubh25 

 

Please see the attached solution, I've added an extra table "Top N selector" for filtering and adjusted Rank Balance Measure and Visual filter to reflect the changes.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

 

Hi @Mariusz,
Thank you very much,
this solved the top N matrix problem I was having.
Just wondering if it also works in another way. e.g., when chosen top 3, it shows only 3 even if 2 or more than 2 source name are selected. 
I tried it by removing the sourcename from the visual and it worked but is there a way that we can have source name as well as only the top 3 throughout the table?

Mariusz
Community Champion
Community Champion

Hi @shubh25 
The below will rank top n on Client and Source.Name granularity. 

Rank Balance 2 = 
IF (
    ISINSCOPE( 'TOP N with Matrix'[Client] ),
    INT(
        RANKX (
            CALCULATETABLE (
                GROUPBY('TOP N with Matrix', 'TOP N with Matrix'[Client], 'TOP N with Matrix'[Source.Name] ),
                ALLSELECTED ( 'TOP N with Matrix'[Client], 'TOP N with Matrix'[Source.Name]  )
            ),
            CALCULATE( SUM( 'TOP N with Matrix'[Balance] ) )
        ) <= MAX( 'Top N Selector'[Value] )
    )
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Mariusz
Community Champion
Community Champion

Hi @shubh25 

 

what would you expect to see as an outcome, top n clients for each Source.Name?

 

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski

 

That is right @Mariusz.
e.g., If two source name are being selected, top 3 clients for both of them, so overall 6.
If only one sourcename is selected, then only 3 (belonging to the selected source name)
Basically the result that the slicer from filter pane is achieving.

Mariusz
Community Champion
Community Champion

Hi @shubh25 

 

Please see the below screenshot, is this what you are looking for?

image.png

 

If so please see the attached file and a link to the article below:

https://www.sqlbi.com/articles/filtering-the-top-3-products-for-each-category-in-power-bi/

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Hi @Mariusz , 

sorry for not being clear in my original question. 

Basically I want a dynamic slicer with the use of which I can either slide to the number of clients that I want to see or choose whether top 3 or 5 clients get displayed. 
I do not want to use the filter pane at all.

Please find attached the screenshot for your understanding.

top n eg.PNG

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.