cancel
Showing results for
Search instead for
Did you mean:
Regular Visitor

## 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

Accepted Solutions
Super User IV

## Re: Filter only one level of a matrix

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])```
4 REPLIES 4
Super User IV

## Re: Filter only one level of a matrix

Hello @Wkeith

You can use something like

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

Regular Visitor

## Re: Filter only one level of a matrix

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])
Super User IV

## Re: Filter only one level of a matrix

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])```
Regular Visitor

## Re: Filter only one level of a matrix

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

#### Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

#### Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

#### Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

#### Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

#### Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors
Top Kudoed Authors