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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ash_cool10
Frequent Visitor

Top 5 with Multiple Field/Criteria

 
Hi There,
 

I have a table with follwing 4 fields

1- CAT

2- SubCAT

3- DetailCAT

4- Sales

 

I have created a Matrix Table with drill down on Cat--> SubCat-->DetailCat with  value is SUM(Sales)

 

I want to show Top 5 of CAT initially on the Matrix Tablec, then when I drill down to next level (SUBCAT), we want to see TOP 5 of SUBCAT, and then when we drill down to next level, we want to see TOP 5 of  DetailCAT

 

Can anyone please help if this is possible ?

 

Thanks in Advance.

Ashish

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

Hi, @ash_cool10 

Please refer to the solution mentioned in this thread.

Filtering the Top 3 products for each category in Power BI 

Pleae try formulas as below:

Rank2 = 
IF (
    ISINSCOPE ( 'Table'[DetailCAT] ),
    RANKX (
        CALCULATETABLE (
            VALUES ( 'Table'[DetailCAT] ),
            ALLSELECTED ( 'Table'[DetailCAT] )
        ),
        [Sales Amount]
    ),
    IF (
        ISINSCOPE ( 'Table'[SubCAT] ),
        VAR SubcatSales = [Sales Amount]
        RETURN
            CALCULATE (
                RANKX ( VALUES ( 'Table'[SubCAT] ), [Sales Amount], SubcatSales ),
                ALLSELECTED ()
            ),
        IF (
            ISINSCOPE ( 'Table'[CAT] ),
            VAR CatSales = [Sales Amount]
            RETURN
                CALCULATE (
                    RANKX ( VALUES ( 'Table'[CAT] ), [Sales Amount], CatSales ),
                    ALLSELECTED ()
                )
        )
    )
)

Then filter the data based on the newly created ranking column.

 

Best Regards,
Community Support Team _ Eason

View solution in original post

2 REPLIES 2
Bhaskarkolli9
Helper I
Helper I

MAG1
Consolidated Account Group
Customer Name
Material

We are also facing same problem can any one give solution if any.

v-easonf-msft
Community Support
Community Support

Hi, @ash_cool10 

Please refer to the solution mentioned in this thread.

Filtering the Top 3 products for each category in Power BI 

Pleae try formulas as below:

Rank2 = 
IF (
    ISINSCOPE ( 'Table'[DetailCAT] ),
    RANKX (
        CALCULATETABLE (
            VALUES ( 'Table'[DetailCAT] ),
            ALLSELECTED ( 'Table'[DetailCAT] )
        ),
        [Sales Amount]
    ),
    IF (
        ISINSCOPE ( 'Table'[SubCAT] ),
        VAR SubcatSales = [Sales Amount]
        RETURN
            CALCULATE (
                RANKX ( VALUES ( 'Table'[SubCAT] ), [Sales Amount], SubcatSales ),
                ALLSELECTED ()
            ),
        IF (
            ISINSCOPE ( 'Table'[CAT] ),
            VAR CatSales = [Sales Amount]
            RETURN
                CALCULATE (
                    RANKX ( VALUES ( 'Table'[CAT] ), [Sales Amount], CatSales ),
                    ALLSELECTED ()
                )
        )
    )
)

Then filter the data based on the newly created ranking column.

 

Best Regards,
Community Support Team _ Eason

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Users online (25)