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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
lherbert501
Post Partisan
Post Partisan

Dynamic Ranking

Hi,

 

I need help ranking and getting the top and bottom of my categories for my total measure.

 

The trouble comes when I want to put it into a single headline row table so I can click the "Top category by total" and the large table below changes dynamically, as I don't believe cards can affect a tablix, and it shows all of that categories data.

 

I've tried some TopN measures but these are static and don't allow the tablix below to change with it.

 

Is this possible? I've included below my data. The bottom ranking has to ignore zero's,also.

 

Screenshot 2025-09-02 160803.png

 

 

1 ACCEPTED SOLUTION

Hello, no it  is not possible as that is the value of a measure

 

You would like to see in the slicer the best and top categories ?


Can this work? You have in automatic the top category in the slicer

 

FBergamaschi_0-1756897718701.png

https://drive.google.com/drive/folders/1QePQY6IYIrtwCr37GjHiIKObuA197OQG?usp=sharing

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

View solution in original post

16 REPLIES 16
v-veshwara-msft
Community Support
Community Support

Hi @lherbert501 ,

Thanks for posting in Microsoft Fabric Community.

You can achieve this by creating two visuals: a selector table and a detail table.

The selector table will only display the top and bottom categories, and when you click on a row there, the detail table will update to show only that category’s data.

Below are the measures used in the setup:

Total1 =
SUM ( CategoryData[Total] )

Top Category Name =
MAXX (
    TOPN ( 1, FILTER ( ALL ( CategoryData[Category] ), [Total1] > 0 ), [Total1], DESC ),
    CategoryData[Category]
)

Bottom Category Name =
MAXX (
    TOPN ( 1, FILTER ( ALL ( CategoryData[Category] ), [Total1] > 0 ), [Total1], ASC ),
    CategoryData[Category]
)

Is Top Or Bottom =
VAR c = SELECTEDVALUE ( CategoryData[Category] )
RETURN IF ( c = [Top Category Name] || c = [Bottom Category Name], 1 )

TopBottom Label =
VAR c = SELECTEDVALUE ( CategoryData[Category] )
RETURN
IF (
    c = [Top Category Name],
    "Top category",
    IF ( c = [Bottom Category Name], "Bottom category" )
)

 

In the selector table, place Category, TopBottom Label, and optionally Total, then apply a visual-level filter where Is Top Or Bottom = 1. This gives you exactly two rows: the top category and the bottom category. Clicking a row in the selector table will cross-filter the detail table.

 

Selector Table:

vveshwaramsft_0-1756901291649.png

Detail Table:

vveshwaramsft_2-1756901370681.png

 

 

Detail Table responding to Selector Table:

vveshwaramsft_1-1756901336150.png

 

I have attached .pbix for your reference.

Hope this helps. Please reach out for further assistance.

Thank you.

 

Shahid12523
Community Champion
Community Champion

- Create a disconnected table with “Top Category” and “Bottom Category” labels.
- Use DAX to calculate the actual top/bottom category names dynamically (ignoring zeros).
- Build a measure that returns the selected category based on the label.
- Use a filter measure (ShowCategory = 1) to show only that category’s data in your main table.

Shahed Shaikh
mh2587
Super User
Super User

1. Create a Rank measure

Category Rank =
RANKX (
    FILTER ( ALL ( 'Category' ), [Total] > 0 ),   // Ignores zeros
    [Total],
    ,
    DESC,
    DENSE
)

2. Create Top Category (Dynamic) measure 

Top Category =
CALCULATE (
    FIRSTNONBLANK ( 'Category'[Category], 1 ),
    FILTER (
        ALL ( 'Category' ),
        [Category Rank] = 1
    )
)

3. Create Bottom Category (Dynamic) measure

Bottom Category =
CALCULATE (
    FIRSTNONBLANK ( 'Category'[Category], 1 ),
    FILTER (
        ALL ( 'Category' ),
        [Category Rank] = CALCULATE ( MAX ( [Category Rank] ), ALL ( 'Category' ) )
    )
)

4. Place in visuals

  • Put Top Category and Bottom Category into a single-row table visual (instead of a card).

  • Clicking one will act as a filter for your tablix (main detail table) because it’s a table visual, not a card.

  • The Bottom Category will automatically ignore zeros due to the 

    FILTER ( ALL ( 'Category' ), [Total] > 0 ).


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Hi @mh2587 ,

 

Thankyou for this. This seems to be on the right lines. It ranks correctly but when it tries to get the top category it exceeds resources.

 

Would there be a way to group it by eg customer to ease the load?

 

Thanks

FBergamaschi
Solution Sage
Solution Sage

I am not sure I understand what you are asking

 

Can you please show an example of the selections you want to make and the expected outcome?

 

Anyway, here is how to get waht you are discussing in a column (I do not think this is what you need though)

 

FBergamaschi_0-1756826771485.png

 

 

Here how to get it with a measure

 

FBergamaschi_1-1756827116970.png

Rank M =
IF (
    ISINSCOPE( 'Fact'[Category] ) && [Total M] <> 0,
    RANKX (
        ALL ('Fact'[Category] ),
        [Total M]
    )
)
 
Total M = SUM ( 'Fact'[Total] )
 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Hi @FBergamaschi 

 

Apologies for not being clearer. 

 

It would need to be a measure. but I would ideally like a card at the top with the top category e.g. category 1. I want to be able to click on the card at the top that is displaying the top category and a whole tablix visual updates on the fly below to only show data for that category. 

 

I'm not sure you can do this with a card, but I'm thinking maybe a tablix to go at the top as 1 row that I could select.

Hi,

One cannot click on a card.  What exactly are you trying to do?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur ,

 

Yes, as I suggested maybe a table would work with one line instead?

 

I want to be able to select both entries at the top and the table below is interactive. 

 

If I click on Category 1 at the top then the table below only shows Category 1 and 130254.

 

Rank Dummy Data.pbix

Hi @lherbert501 

tablix sounds like Reporting Services to me 🙂 

 

This is another planet...

 

So please can you show me what you want to do? You cannot filter with a card I am afraid but please show me

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Hi @FBergamaschi 

 

Tablix, table Visual.. All the same 😀

 

I want to be able to select both entries at the top and the table below is interactive. 

 

If I click on Category 1 at the top then the table below only shows Category 1 and 130254.

 

Rank Dummy Data.pbix

hi @lherbert501 ,

here is my version, so we can discuss based on pbix stuff

 

https://drive.google.com/drive/folders/1QePQY6IYIrtwCr37GjHiIKObuA197OQG?usp=sharing

 

Can you tell me if this is OK or you need modifications?

 

You cannot click on a card to create a filter though

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Hi @FBergamaschi 

 

On your PBIX, if you changed the cards to single line tables, is it not possible to select the single line table that displays top category and use this as the interactive selector for the table?

Hello, no it  is not possible as that is the value of a measure

 

You would like to see in the slicer the best and top categories ?


Can this work? You have in automatic the top category in the slicer

 

FBergamaschi_0-1756897718701.png

https://drive.google.com/drive/folders/1QePQY6IYIrtwCr37GjHiIKObuA197OQG?usp=sharing

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Hi @FBergamaschi 

 

Okay thankyou for confirming.

 

Im wondering if its possible to simply put the category field into that 1 line table at the top and put a measure visual filter on the 1 line table. e.g. ranking of the lowest thats not zero and set this to 1?

This way the category would still be dynamic

Yes indeed, I did that

 

same link

 

is that a solution now?

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Yes that's working now thankyou.

 

Thankyou for your time on this. Its much appreciated @FBergamaschi 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.