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

TopN Filter With Changing Totals Issue

Hello!

I created a WhatIf filter in order to have a slicer (TopN) that would display the number of 'Broker Groups' and their respective amounts. The filter is working correctly when I select a number, the right amount of brokers gets displayed with their amounts. However, my table total shows the whole amount for all the brokers. The way that I want it to work is if I selected the top N amount of records, the table's total should display the sum of those N records, not the total amount of all records.

 

Thank you in advance! 😄

 

topn.PNG

 

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Hello @mvelazquez 

We can use the TOPN with the amount directly rather than using RANKX and then we just need to bring back the subset of brokers like so.

TopN Value = 
VAR SelectedTop = SELECTEDVALUE ( 'TopN'[TopN],0 )
VAR _FilterContext = VALUES ( 'GROUP_BROKER'[GROUP_BROKER_NM] )

RETURN
SWITCH(
    TRUE(),
    SelectedTop = 0, [TOTAL_PREM],
    CALCULATE(
        [TOTAL_PREM],
        TOPN ( SelectedTop, ALL ( 'GROUP_BROKER'[GROUP_BROKER_NM] ), [TOTAL_PREM] ),
        _FilterContext
    )
)

TopNBroker.jpg

View solution in original post

2 REPLIES 2
jdbuchanan71
Super User
Super User

Hello @mvelazquez 

We can use the TOPN with the amount directly rather than using RANKX and then we just need to bring back the subset of brokers like so.

TopN Value = 
VAR SelectedTop = SELECTEDVALUE ( 'TopN'[TopN],0 )
VAR _FilterContext = VALUES ( 'GROUP_BROKER'[GROUP_BROKER_NM] )

RETURN
SWITCH(
    TRUE(),
    SelectedTop = 0, [TOTAL_PREM],
    CALCULATE(
        [TOTAL_PREM],
        TOPN ( SelectedTop, ALL ( 'GROUP_BROKER'[GROUP_BROKER_NM] ), [TOTAL_PREM] ),
        _FilterContext
    )
)

TopNBroker.jpg

@jdbuchanan71 Thank you very much! Your approach opens up many other possibilities when working with slicers. I will definitely incorporate it!

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