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
derekli1700
Helper III
Helper III

How to make a Top/Bottom 20 Row Slicer for a Matrix Table

Hi - currently i have a matrix table that shows all store monthly sales transactions and each store's respective top 5 customer's sales based off a date slicer. The Table's rows are comprised of a DISTINCT table of the stores and customers, Year and Year-Month columns and the Value is a Sales Measure.

derekli1700_2-1748399321022.png

 

I'm struggling to make a Tile Slicer that shrinks the table to show Top 20/Bottom 20 stores in the table (depending on the date slicer) which matches up with the results of my data's pivot table on excel (attached). 

My current PBIX file attached as well

To illustrate what i'm doing currently - I made the table's sales value by these measures:

Total Sales = SUM( Overview[Sales])

Then i used this measure as the Matrix Table value:

MEASURE-Sales = 
VAR CurrentRank = [Customer Rank (Fixed)]
VAR IsTop5Customer = IF(NOT ISBLANK(CurrentRank), CurrentRank <= 5, FALSE)

RETURN
IF(
    ISINSCOPE('Unique Customers'[Customer]),
    IF(
        IsTop5Customer,
        [Total Sales],
        BLANK()
    ),
    CALCULATE(
        [Total Sales],
        REMOVEFILTERS('Unique Customers'[Customer])
    )
)

As mentioned before - i also made the table show each store's top 5 customers via this rank:

Customer Rank (Fixed) = 
VAR SelectedDates =
    CALCULATETABLE(
        VALUES('Date'[Date]),
        ALLSELECTED('Date')
    )

VAR CurrentCustomer = SELECTEDVALUE('Unique Customers'[Customer])
VAR CurrentSite = SELECTEDVALUE('Unique Stores'[Store]) 
VAR CustomerSales =
    CALCULATE(
        [Total Sales],
        KEEPFILTERS(SelectedDates),
        ALL('Date'), 
        'Unique Stores'[Store] = CurrentSite
    )

RETURN
IF(
    ISINSCOPE('Unique Customers'[Customer]),
    IF(NOT ISBLANK(CustomerSales) && CustomerSales > 0,
        RANKX(
            FILTER(
                ALL('Unique Customers'[Customer]),
                CALCULATE(
                    [Total Sales],
                    KEEPFILTERS(SelectedDates),
                    ALL('Date'),
                    'Unique Stores'[Store] = CurrentSite
                ) > 0
            ),
            CALCULATE(
                [Total Sales],
                KEEPFILTERS(SelectedDates),
                ALL('Date'),
                'Unique Stores'[Store] = CurrentSite
            ),
            ,
            DESC,
            DENSE
        )
    )
)

My date table is below for reference (capped at current month for YOY measure purposes not mentioned above):

Date = 
ADDCOLUMNS (
    CALENDAR (
        DATE (2023, 1, 1),
        DATE (2025, 4, 30)
    ),
    "Year", YEAR([Date]),
    "Year-Month", FORMAT([Date], "yyyy-MM"),
    "Year-Month sort", EOMONTH([Date], 0)
)

Would like some guidance as the numbers dont match with my excel pivot table numbers when i select a specific date range/overall date range or skew/exceeds query resources if Year-Month is added to the rows. 

2 ACCEPTED SOLUTIONS
Ashish_Excel
Super User
Super User

Hi,

Try this measure

Measure = if(ISINSCOPE('Unique Customers'[Customer]),CALCULATE([Total Sales],TOPN(5,ALL('Unique Customers'[Customer]),[Total Sales]),VALUES('Unique Customers'[Customer])),CALCULATE([Total Sales],TOPN(5,ALL('Unique Stores'[Store]),[Total Sales]),VALUES('Unique Stores'[Store])))

Ashish_Excel_0-1748400913141.png

 

View solution in original post

v-echaithra
Community Support
Community Support

Hi @derekli1700 ,

Thanks for reaching out to Microsoft Community.

Please refer to this document which helps you to implement a toggleable Top 20/Bottom 20 Store Slicer.
Dynamically Display Top N and Bottom N Records in One Power BI Chart
How to configure a Top X Slicer in Power BI | Magnetism Solutions | NZ (Auckland, Wellington, Christ...

If this post helps, please give us Kudos and consider marking it Accept as solution to assist other members in finding it more easily.

Regards,
Chaithra.

View solution in original post

6 REPLIES 6
v-echaithra
Community Support
Community Support

Hi @derekli1700 ,

We wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

 

Regards,
Chaithra.

v-echaithra
Community Support
Community Support

Hi @derekli1700 ,

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

 

Regards,
Chaithra.

v-echaithra
Community Support
Community Support

Hi @derekli1700 ,

Thanks for reaching out to Microsoft Community.

Please refer to this document which helps you to implement a toggleable Top 20/Bottom 20 Store Slicer.
Dynamically Display Top N and Bottom N Records in One Power BI Chart
How to configure a Top X Slicer in Power BI | Magnetism Solutions | NZ (Auckland, Wellington, Christ...

If this post helps, please give us Kudos and consider marking it Accept as solution to assist other members in finding it more easily.

Regards,
Chaithra.

Ashish_Excel
Super User
Super User

Hi,

Try this measure

Measure = if(ISINSCOPE('Unique Customers'[Customer]),CALCULATE([Total Sales],TOPN(5,ALL('Unique Customers'[Customer]),[Total Sales]),VALUES('Unique Customers'[Customer])),CALCULATE([Total Sales],TOPN(5,ALL('Unique Stores'[Store]),[Total Sales]),VALUES('Unique Stores'[Store])))

Ashish_Excel_0-1748400913141.png

 

is there a way to make it into a tile slicer so that it can shrink once they select "top 20" or "bottom 20" instead of it always being shrunk?

derekli1700_0-1748401525153.png

 

Yes but that requires some work.  Will take my time which i do not want to onvest right now.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.

Top Solution Authors
Top Kudoed Authors