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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Duplicate Value Count

Dear All ,

 

I want to get the count of the duplicate values as shown below. Below shows my table.

Predecessr FollOn Doc
1030172720 1200261222
1030172740 1200261228
1030172740 1200261441
1030172740 1200261853
1030172740 1200262095
1030172740 1200524255
1030172749 1200262308
1030172751 1200262310
1030172756 1200261689
1030172758 1200261711
1030172759  

 

 

What I need is below output. It shows in Count column.

Predecessr FollOn Doc Count
1030172720 1200261222 1
1030172740 1200261228 1
1030172740 1200261441 2
1030172740 1200261853 3
1030172740 1200262095 4
1030172740 1200524255 5
1030172749 1200262308 1
1030172751 1200262310 1
1030172756 1200261689 1
1030172758 1200261711 1
1030172759   1

 

But I got the below record as my output. How can I get the above results. Can someone help me please. 

 
Count = CALCULATECOUNT('Count of Delivery (Sheet1)'[Predecessr]), FILTER('Count of Delivery (Sheet1)','Count of Delivery (Sheet1)'[Predecessr] = EARLIER('Count of Delivery (Sheet1)'[Predecessr])))
 
Count
1
5
5
5
5
5
1
1
1
1
1
1 ACCEPTED SOLUTION

ALLSELECTED has no meaning in a calculated colum.  You can also drop the OrderBy.

 

Count2 = ROWNUMBER(SUMMARIZE('Table',[Predecessr],[FollOn Doc]),PARTITIONBY([Predecessr]))

View solution in original post

7 REPLIES 7
Ahmedx
Super User
Super User

pls try this

Screenshot_2.png

ALLSELECTED has no meaning in a calculated colum.  You can also drop the OrderBy.

 

Count2 = ROWNUMBER(SUMMARIZE('Table',[Predecessr],[FollOn Doc]),PARTITIONBY([Predecessr]))
Anonymous
Not applicable

Thank you. This worked for me. 

that's right, I write everything out of habit

Ahmedx
Super User
Super User

I wrote a video for you, look how easy it is

https://1drv.ms/v/s!AiUZ0Ws7G26RiwdotVHIwqn4muwQ?e=jZ54gz

Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Grouped Rows" = Table.Group(Source, {"Predecessr"}, {{"All", each Table.AddIndexColumn(_,"Count",1,1), type table [Predecessr=number, FollOn Doc=any, Count=number]}}),
    #"Expanded All" = Table.ExpandTableColumn(#"Grouped Rows", "All", {"FollOn Doc", "Count"}, {"FollOn Doc", "Count"})
in
    #"Expanded All"

Hope this helps.

Ashish_Mathur_0-1696661528352.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Power BI has no concept of row numbers. You need to bring your own index.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc+5DcAwDAPAVQLVLiha8jOL4f3XCFIpCuL6QJBcSxQV2tkJKaIE2JSk7BJmycbRzPRow+vJiOn/5jT6x2bkKvIW15cpsrXY0sbMNsK65g/+9F2y9w0=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Predecessr = _t, #"FollOn Doc" = _t]),
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Count", (k)=> Table.RowCount(Table.SelectRows(#"Added Index",each [Index]<=k[Index] and [Predecessr]=k[Predecessr])))
in
    #"Added Custom"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors