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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.