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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

How to count duplicate counts of a string value and express it as TOP N and Others?

String value TOP N and Others
 

Hello teachers, I am a Korean student.

I want to count the duplicate values ​​of string data and express the TOP 5 and the remaining values.

I am able to count the total string values, but not able to count the duplicates of each value.

Below is a simple example.

 

OrderDuplicate Count ProdutRankTotal Count
A3 A13
B2 B22
B2 C32
A3 Others 2
A3    
C2    
D1    
F1    
C2    

 

I plan to use these values ​​for matrix objects and map objects.

Please help me. Sir and Maam 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

You can refer to the following example.

1.Create a calculated table

Table 2 = var a=SUMMARIZE('Table',[Order])
var b={"Others"}
return UNION(a,b)

2.Then create a measure

Measure = var a=SUMMARIZE('Table',[Order],"Countrows",COUNTROWS('Table'))
var b=TOPN(3,a,[Countrows],DESC)
var c=SUMMARIZE(b,'Table'[Order])
return SWITCH(TRUE(),SELECTEDVALUE('Table 2'[Order])="Others",SUMX(a,[Countrows])-SUMX(b,[Countrows]),SELECTEDVALUE('Table 2'[Order]) in c,SUMX(FILTER(a,[Order] in VALUES('Table 2'[Order])),[Countrows]))

Put the column of table 2 and the measure to a table visual

vxinruzhumsft_0-1683878857382.png

 

Best Regards!

Yolo Zhu

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

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous 

You can refer to the following example.

1.Create a calculated table

Table 2 = var a=SUMMARIZE('Table',[Order])
var b={"Others"}
return UNION(a,b)

2.Then create a measure

Measure = var a=SUMMARIZE('Table',[Order],"Countrows",COUNTROWS('Table'))
var b=TOPN(3,a,[Countrows],DESC)
var c=SUMMARIZE(b,'Table'[Order])
return SWITCH(TRUE(),SELECTEDVALUE('Table 2'[Order])="Others",SUMX(a,[Countrows])-SUMX(b,[Countrows]),SELECTEDVALUE('Table 2'[Order]) in c,SUMX(FILTER(a,[Order] in VALUES('Table 2'[Order])),[Countrows]))

Put the column of table 2 and the measure to a table visual

vxinruzhumsft_0-1683878857382.png

 

Best Regards!

Yolo Zhu

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.