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
Wkeith
Helper II
Helper II

Filter only one level of a matrix

Is it possible to filter only one level of a matrix? Lets say I have two levels in a matrix State and City. State displays total revenue per state as it should. But when I drill down to city, I only want it to display the top 20 cities based on their revenue instead of lisiting all the citites and their revenue.

 

 

However, when I add this into the visual level filter it also filters my first level of the matrix and will only display the revenue amount of the top 20 cities in the state format. 

 

How do I get it to show total revenue by State for every data point in the first level of the matrix but then when I drill down it shows only the top 20 citites by revenue? 

1 ACCEPTED SOLUTION

Hello @Wkeith 

Sorry about that, had to take it one step further, give this a try.

Filter Measure = 
VAR
    RankingContext = VALUES ( FactSales[City] )
RETURN
IF ( ISINSCOPE ( FactSales[City] ),
    CALCULATE (
        [TOTALREVENUE],
        TOPN ( 20, ALL ( FactSales[City] ), [TOTALREVENUE] )
        ,RankingContext
    ),
    [Sales Amount])

View solution in original post

4 REPLIES 4
jdbuchanan71
Super User
Super User

Hello @Wkeith 

You can use something like 

 

Measure =
IF (
    ISINSCOPE ( Table[City] ),
    CALCULATE ( TOPN ( 20, VALUES ( Table[City] ), [Amount] ) ),
    [Amount]
)

 

I'm using this formula and its giving me revenue numbers for the state level but when I drill into the city level it returns the city name as the values instead of a revenue number... any idea why? 
 
Filter Measure = if(isinscope(FactSales[City]), calculate(topn(20,values(FactSales[City]),[TOTALREVENUE])),[TOTALREVENUE])

Hello @Wkeith 

Sorry about that, had to take it one step further, give this a try.

Filter Measure = 
VAR
    RankingContext = VALUES ( FactSales[City] )
RETURN
IF ( ISINSCOPE ( FactSales[City] ),
    CALCULATE (
        [TOTALREVENUE],
        TOPN ( 20, ALL ( FactSales[City] ), [TOTALREVENUE] )
        ,RankingContext
    ),
    [Sales Amount])

Had to add a small filter to get the cities with 0 revenue to not show but yup this worked! Thanks for the help! 

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