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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
badger123
Resolver I
Resolver I

Treemap top n per group

Hello,

 

I'm using treemap visual with category for Group, name for Details and sum of phrase volumes for Values. I am trying to show the top 10 names per group (category) by volume. However, when I set top n, it doesn't work at a group level, it filters to the top 10 across all groups. Is there any way to achieve this?

 

Here is a sample of my tables and data. The tables are joined by phrase. 

 

Table1  
NamePhraseCategory
name 1phrase 1A
name 1phrase 2A
name 1phrase 2B
name 1phrase 3C
name 2phrase 4A
name 2phrase 4B
name 3phrase 4A
name 3phrase 4B
name 3phrase 5A
name 3phrase 5B
name 3phrase 5C

 

Table2 
PhraseVolume
phrase 110
phrase 220
phrase 330
phrase 440
phrase 55

 

Desired output, example top 1 per group: 

Aphrase 4
Bphrase 4
Cphrase 3
2 REPLIES 2
v-xicai
Community Support
Community Support

Hi @badger123 ,

 

You can create measure Top N in table1.

 

Top N = CALCULATE(MAXX(TOPN(1,FILTER(Table2,MAX(Table2[Phrase])=MAX(Table1[Phrase])),Table2[Volume],DESC),Table2[Phrase]),FILTER(ALLSELECTED(Table1),Table1[Category]=MAX(Table1[Category])))

 

3.png

 

 

 

 

Here is my test pbix: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EUC2yuOyRGtMtG-VRO...

 

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @v-xicai 

 

Thank you! This works perfectly, but I am trying to achieve the following:

Desired output:

Aname 3
Bname 3
Cname 1

 

Sorry, I got it wrong in my original note! Any thoughts on how to do this? I also only provided a sample of my tables, but I would like to be able to calculate top 10 names per category.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.