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
abisrani
Helper I
Helper I

Top N products with their sales

Hello Community,

 

I am looking for a solution for my report where I've got a table visual, a date slicer, and a slicer to select the quarter(Q1, Q2, Q3, Q4).

When I select a date range, my result should have the top 10 products with their sales.

The catch is I have another filter that has 4 quarters checked(selected) and I do not want to modify or change the products in the table visual when I select only one quarter.

Let us say I've selected Q1 and then the top 10 products should be the same but I am seeing the sales numbers for Q1 only.

 

Thank you.

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

Hi @abisrani 

You can refer to the following solution.

Sample data 

vxinruzhumsft_0-1710744858460.png

1.Create a calendar table and create a relationship between tables.

vxinruzhumsft_1-1710744905286.png

 

2.Create quarter table

vxinruzhumsft_2-1710744938794.png

3.Create a measure

MEASURE =
VAR a =
    SUMMARIZE (
        TOPN ( 10, ALLSELECTED ( 'Sales' ), CALCULATE ( SUM ( 'Sales'[Value] ) ), DESC ),
        [Product]
    )
RETURN
    CALCULATE (
        SUM ( 'Sales'[Value] ),
        FILTER (
            'Sales',
            "Q"
                & QUARTER ( 'Sales'[Date] )
                    IN VALUES ( 'Quarter'[Quarter] )
                        && 'Sales'[Product] IN a
        )
    )

4.Then put the quarter of quarter table to a slicer and the measure to the table.

Output

vxinruzhumsft_3-1710745054171.png

 

Best Regards!

Yolo 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

8 REPLIES 8
v-xinruzhu-msft
Community Support
Community Support

Hi @abisrani 

You can refer to the following solution.

Sample data 

vxinruzhumsft_0-1710744858460.png

1.Create a calendar table and create a relationship between tables.

vxinruzhumsft_1-1710744905286.png

 

2.Create quarter table

vxinruzhumsft_2-1710744938794.png

3.Create a measure

MEASURE =
VAR a =
    SUMMARIZE (
        TOPN ( 10, ALLSELECTED ( 'Sales' ), CALCULATE ( SUM ( 'Sales'[Value] ) ), DESC ),
        [Product]
    )
RETURN
    CALCULATE (
        SUM ( 'Sales'[Value] ),
        FILTER (
            'Sales',
            "Q"
                & QUARTER ( 'Sales'[Date] )
                    IN VALUES ( 'Quarter'[Quarter] )
                        && 'Sales'[Product] IN a
        )
    )

4.Then put the quarter of quarter table to a slicer and the measure to the table.

Output

vxinruzhumsft_3-1710745054171.png

 

Best Regards!

Yolo Zhu

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

 

Daniel29195
Super User
Super User

@abisrani 

you can turn off the interaction between the slicer and the visual. 

 

Daniel29195_0-1709468305394.png

 

 

let me know if this helps. 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

Thanks for the suggestion. Actually, I want to see the changes for those applied filters. It is just that I want to retain the top the product list.
So example, if I am first seeing the top 10 in all the quarters sales and then selecting only 1st quarter, then I want to see the sales for the same products.

if I am first seeing the top 10 in all the quarters sales and then selecting only 1st quarter, then I want to see the sales for the same products.

The only way to accomplish that is to use a shadow copy of your dataset for the slicer and then use measures as visual filters.

Ashish_Mathur
Super User
Super User

Hi,

Your question is not clear.  Share some data to work with and show the expected result.


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

abisrani_0-1709564970391.png

Hello Ashish,
So the logic I am looking for is that when I change the date above, it should show me top 10 products and then when I change the Quarter from the Quarter slicer(say selecting Quarter 1), it should not affect the top 10 products and should show me the sales for the same 10 products in the Quarter 1.

Thank you.

Not sure of how much i can help but i'll try.  Share the download link of the PBI file.


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

You can get either or, but not both at the same time.  Teach your users how to use the filter pane advanced filtering (including Top N)  and allow them to personalize visuals.

 

You _could_  use disconnected tables to feed your slicers, and measures as visual filters.  But a robust data model is preferable.

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.