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
Ritvik777
Frequent Visitor

Display Top 3 products on Drill Down

Hi Everyone!

 

Greetings of the day.

 

I require some help on the Scenario below:

 

I am displaying Sales by Country, Region and Product in a Bar Chart. But the User requirement is such that on drilling down at the Product Level, they only want the Top 3 Products, However the catch is that at an overall level (Country, Region) they would want to see the complete Sales for that particular dimension i.e Country & Region. 

 

Please find Below screenshots:

 

1.  At the Country level this is what they want, so no issues here.

 

Ritvik777_0-1654254501637.png

 

2. On drilling Down to a particular country say India at the Region level, this is fine as well.

Ritvik777_1-1654254614719.png

 

3. But on drilling to the Product level say for West Region, they only want the top 3 Products which is d,l,t is this case and not all products.

 

Ritvik777_2-1654254704674.png

 

 

Requesting you support on the Scenario above.

 

Thanks and Best Regards!!

 

 

 

 

 

 

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

Hi @Ritvik777 ,

 

Please try this code:

Measure =
VAR _c3 =
    CALCULATETABLE (
        TOPN (
            3,
            VALUES ( 'Table'[Contry] ),
            CALCULATE ( SUM ( 'Table'[Values] ) ), DESC
        ),
        ALLSELECTED ( 'Table' )
    )
VAR _r3 =
    CALCULATETABLE (
        TOPN (
            3,
            VALUES ( 'Table'[Region] ),
            CALCULATE ( SUM ( 'Table'[Values] ) ), DESC
        ),
        ALLSELECTED ( 'Table' )
    )
VAR _p3 =
    CALCULATETABLE (
        TOPN (
            3,
            VALUES ( 'Table'[Product] ),
            CALCULATE ( SUM ( 'Table'[Values] ) ), DESC
        ),
        ALLSELECTED ( 'Table' )
    )
VAR _c =
    IF ( SELECTEDVALUE ( 'Table'[Contry] ) IN _c3, SUM ( 'Table'[Values] ) )
VAR _r =
    IF ( SELECTEDVALUE ( 'Table'[Region] ) IN _r3, SUM ( 'Table'[Values] ) )
VAR _p =
    IF ( SELECTEDVALUE ( 'Table'[Product] ) IN _p3, SUM ( 'Table'[Values] ) )
RETURN
    SWITCH (
        FALSE (),
        ISBLANK ( SELECTEDVALUE ( 'Table'[Contry] ) ), _c,
        ISBLANK ( SELECTEDVALUE ( 'Table'[Region] ) ), _r,
        ISBLANK ( SELECTEDVALUE ( 'Table'[Product] ) ), _p
    )

 

Result:

vchenwuzmsft_0-1654595643285.gif

 

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-chenwuz-msft
Community Support
Community Support

Hi @Ritvik777 ,

 

Please try this code:

Measure =
VAR _c3 =
    CALCULATETABLE (
        TOPN (
            3,
            VALUES ( 'Table'[Contry] ),
            CALCULATE ( SUM ( 'Table'[Values] ) ), DESC
        ),
        ALLSELECTED ( 'Table' )
    )
VAR _r3 =
    CALCULATETABLE (
        TOPN (
            3,
            VALUES ( 'Table'[Region] ),
            CALCULATE ( SUM ( 'Table'[Values] ) ), DESC
        ),
        ALLSELECTED ( 'Table' )
    )
VAR _p3 =
    CALCULATETABLE (
        TOPN (
            3,
            VALUES ( 'Table'[Product] ),
            CALCULATE ( SUM ( 'Table'[Values] ) ), DESC
        ),
        ALLSELECTED ( 'Table' )
    )
VAR _c =
    IF ( SELECTEDVALUE ( 'Table'[Contry] ) IN _c3, SUM ( 'Table'[Values] ) )
VAR _r =
    IF ( SELECTEDVALUE ( 'Table'[Region] ) IN _r3, SUM ( 'Table'[Values] ) )
VAR _p =
    IF ( SELECTEDVALUE ( 'Table'[Product] ) IN _p3, SUM ( 'Table'[Values] ) )
RETURN
    SWITCH (
        FALSE (),
        ISBLANK ( SELECTEDVALUE ( 'Table'[Contry] ) ), _c,
        ISBLANK ( SELECTEDVALUE ( 'Table'[Region] ) ), _r,
        ISBLANK ( SELECTEDVALUE ( 'Table'[Product] ) ), _p
    )

 

Result:

vchenwuzmsft_0-1654595643285.gif

 

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ritvik777
Frequent Visitor

Hi Ritesh,

 

This helps. 

 

But still looking for an exact solution for the business requirement.  

 

Thanks for reaching out though. 

 

Best Regards,

Ritvik 

ribisht17
Super User
Super User

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.

Top Solution Authors