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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
MadsEmil
Frequent Visitor

Remove measure filter on matrix. for calculating total

I have a matrix where I am using a measure to show only the top N firms (along the lines of this post). However, I would like the totals shown in the matrix to be the unfiltered totals, that is, for all firms, and not only for the top N firms. The matrix has a hierarchy of Category -> Firm, and I would like to show the top N firms within each category. To illustrate, in the image below is the matrix before being filtered.

Screendump.jpg

If I apply the top N filter and show only the, say, top 5 firms, I currently get the below.

Currentoutput.jpg

However, what I would like is for the totals to remain unchanged, as in the image below.

Desiredoutputmatrix.jpg

I find it very tricky to do this as the filter is a measure, so I cannot simply use REMOVEFILTERS or something like that. There are many external filters that should be possible to apply to the matrix, so using ALL is not an option either.

Data and DAX:

The data is provided in the table at the bottom. I am using the following DAX objects currently.

 

TopN_Filter_Table = GENERATESERIES(1, 10, 1)
Sum_of_amount = SUM(Table1[Amount])
RankX_Measure = 
    VAR _CAT = MAX(Table1[Category])
RETURN
    RANKX(
        FILTER(
            ALLSELECTED(Table1),
            Table1[Category] = _CAT
        ),
        CALCULATE(
            [Sum_of_amount],
            ALLEXCEPT(
                Table1,
                Table1[Category],
                Table1[Firm]
            )
        ),,, DENSE
    )
TopN_Filter_Measure = 
    IF(
        [RankX_Measure]<=SELECTEDVALUE(TopN_Filter_Table[Top N], 11),
        1, 
        0
    )

 

I then apply the TopN_Filter_Measure to the filter pane of the matrix and filter it as TopN_Filter_Measure = 1.

 

CategoryFirmAmount
Category1Firm13141
Category1Firm2926
Category1Firm3535
Category1Firm489
Category1Firm579
Category1Firm6323
Category1Firm78462
Category1Firm864
Category1Firm9338
Category1Firm103279
Category1Firm127
Category1Firm2182
Category1Firm3818
Category1Firm428
Category1Firm545
Category1Firm690
Category1Firm74523
Category1Firm853
Category1Firm960
Category1Firm10287
Category1Firm1161
Category1Firm280
Category1Firm3339
Category1Firm4887
Category1Firm549
Category1Firm689
Category1Firm74848
Category1Firm8204
Category1Firm9586
Category1Firm10834
Category2Firm1120
Category2Firm2205
Category2Firm36
Category2Firm4903
Category2Firm5159
Category2Firm65942
Category2Firm785
Category2Firm8399
Category2Firm973
Category2Firm108161
Category2Firm1164
Category2Firm2493
Category2Firm34066
Category2Firm4848
Category2Firm5226
Category2Firm6436
Category2Firm747
Category2Firm8241
Category2Firm9516
Category2Firm10664
1 ACCEPTED SOLUTION
johnt75
Super User
Super User

I think that you can adapt the technique described in https://www.sqlbi.com/articles/filtering-the-top-products-alongside-the-other-products-in-power-bi/  to achieve what you're looking for.

One option would be to rename the "Others" row "Total", and calculate as the sum of Others + the values actually shown.

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

I think that you can adapt the technique described in https://www.sqlbi.com/articles/filtering-the-top-products-alongside-the-other-products-in-power-bi/  to achieve what you're looking for.

One option would be to rename the "Others" row "Total", and calculate as the sum of Others + the values actually shown.

This is excellent, thank you very much! I'll write a reply with my final solution when I have it, for anyone interested.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI 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.

Top Solution Authors