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
Marley2100
New Member

How to count the number of identical IDs in a column?

Dear community, 

 

I am very new to PowerBI and have been searching for a workable solution for my issue for some time. I believe that the solution must be rather simple, but I could not make any of the proposed solutions work.

 

My goal: I have a table with 2 columns: ID and Product. Some IDs are duplicated. I want to add a third column in which the number of duplications for the ID in the same row is pointed out. 

 

Example result (Table1):

IDProductNo of Duplicates
123A1
124B2
124C2
125D1
126E1
127F3
127G3
127H3

 

Progress: 

I tried a couple of formulas, but somehow fishing in the dark. Especially, I dont get the EARLIER working, which I assume could solve the problem at hand. 

 

 

 

No of Duplicates = CALCULATE(
    COUNT('Table1'[ID]), 
    FILTER('Table1', 'Table1'[ID] = EARLIER(ID)))

 

 

 

 

 

No of Duplicates = 
CALCULATE (
    COUNTROWS(FILTER('Table1',
        'Table1'[ID]='Table1'[ID]

    )

))

 

 

 

 

If someone could help me here, that would be highly appreciated. Thanks a lot for any support in advance.

 

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@Marley2100 

Measure = calculate(count(tbl[id]),allexcept(tbl,tbl[id]))

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

=CALCULATE(COUNTROWS(Data),FILTER(Data,Data[ID]=EARLIER(Data[ID])))

Untitled.png


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

@Marley2100 

Measure = calculate(count(tbl[id]),allexcept(tbl,tbl[id]))

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

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.