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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.