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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Kcponakala
Frequent Visitor

Top N Categories and products of each category

Hi,

I need to show top N categories and their production in the Matrix with Catg--> Product heirarchy.

Please help me on this

Top 3 Categories   
CategoryProductSalesRank
Catg1 1003
 PROD180 
 PROD220 
Catg2 1502
 PROD3100 
 PROD420 
 PROD530 
Catg3 3001
 PROD6100 
 PROD7200 

 

Thanks,

Kalyan

1 ACCEPTED SOLUTION
v-gizhi-msft
Community Support
Community Support

Hi,

 

Please try this measure:

Measure =
IF (
    ISINSCOPE ( 'Table'[Product] ),
    BLANK (),
    RANKX (
        SUMMARIZE (
            ALLSELECTED ( 'Table' ),
            'Table'[Category],
            "Total", SUM ( 'Table'[Sales] )
        ),
        [Total],
        SUM ( 'Table'[Sales] ),
        DESC,
        DENSE
    )
)

The result shows:

20.PNG

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto

View solution in original post

3 REPLIES 3
v-gizhi-msft
Community Support
Community Support

Hi,

 

Please try this measure:

Measure =
IF (
    ISINSCOPE ( 'Table'[Product] ),
    BLANK (),
    RANKX (
        SUMMARIZE (
            ALLSELECTED ( 'Table' ),
            'Table'[Category],
            "Total", SUM ( 'Table'[Sales] )
        ),
        [Total],
        SUM ( 'Table'[Sales] ),
        DESC,
        DENSE
    )
)

The result shows:

20.PNG

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto

edhans
Super User
Super User

While certianly possible, this would be much MUCH easier for us to help to get a copy of  your source table data, not your matrix. Otherwise we have to recreate the data for you.

 

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.