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

How to filter on topN for each category

Hi there,

 

I think I have a straight forward question that many of you probably might answer in a matter of seconds.
But somehow, it doesn't seem like I can get it to work.

I have a matrix (see below) showing the top places, their names and what movies they were in.

 

What I would like to do is to filter in a way so that I only get the place with the highest total for each movies.

So I expect to have only 8 lines (8 different movies) with each showing the place that was most often used in that specific movie.

 

How in the world do I manage to get that?

 

Thanks in advance.

Capture.PNG

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @CHFarver ,

 

You could either create a measure to get the highest total for each movies and filter total places = higest total, or create a measure to rank the total places for each movies and filter rank = 1.

For example:

measure 1 =
var _max_each_movies = MAXX(ALLEXCEPT('Table','Table'[Movie]),[Total Places])
return
IF([Total Places] = _max_each_movies,[Total Places],BLANK())
Or

measure 2 = RANKX(ALLEXCEPT('Table','Table'[Movie]),[Total Places],,DESC)
Then add measure2 to visual filter set value = 1.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @CHFarver ,

 

You could either create a measure to get the highest total for each movies and filter total places = higest total, or create a measure to rank the total places for each movies and filter rank = 1.

For example:

measure 1 =
var _max_each_movies = MAXX(ALLEXCEPT('Table','Table'[Movie]),[Total Places])
return
IF([Total Places] = _max_each_movies,[Total Places],BLANK())
Or

measure 2 = RANKX(ALLEXCEPT('Table','Table'[Movie]),[Total Places],,DESC)
Then add measure2 to visual filter set value = 1.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
CHFarver
Frequent Visitor

Total Places measure is a simple count of the places in the Dialogue table

CHFarver
Frequent Visitor

Also this is my data model

Capture.PNG

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.