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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
setis
Post Partisan
Post Partisan

Calculated column of count occurrences of a string in a table

Dear all,

 

I'm trying to calculate on a calculated column the nr of different names for every CaseID

 

CaseID Name      CC

  A1       Peter       2

  A2          Peter    1

  A1        Ana         2

  A3        Tom       1

 

 

Could somebody point me in the right direction, please?

 

3 ACCEPTED SOLUTIONS
v-frfei-msft
Community Support
Community Support

Hi @setis ,

 

To create a calculated column as below.

 

CC = 
CALCULATE (
    DISTINCTCOUNT ( Table1[name] ),
    FILTER ( Table1, Table1[Case ID] = EARLIER ( Table1[Case ID] ) )
)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column

=CALCULATE(DISTINCTCOUNT(Data[Name]),FILTER(Data,Data[CaseID]=EARLIER(Data[CaseID])))

Hope this helps.


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

View solution in original post

Arjunarao
Resolver I
Resolver I

Hi setis,
You can achive with Group by & Merge Transforamtion.
Please check the screens and file.

 

https://drive.google.com/open?id=1wTm4HXqDz-J_-LugxyQ3RHL-_tkhB4EK

 

 

1.JPG2.JPG

View solution in original post

4 REPLIES 4
Arjunarao
Resolver I
Resolver I

Hi setis,
You can achive with Group by & Merge Transforamtion.
Please check the screens and file.

 

https://drive.google.com/open?id=1wTm4HXqDz-J_-LugxyQ3RHL-_tkhB4EK

 

 

1.JPG2.JPG

Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column

=CALCULATE(DISTINCTCOUNT(Data[Name]),FILTER(Data,Data[CaseID]=EARLIER(Data[CaseID])))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-frfei-msft
Community Support
Community Support

Hi @setis ,

 

To create a calculated column as below.

 

CC = 
CALCULATE (
    DISTINCTCOUNT ( Table1[name] ),
    FILTER ( Table1, Table1[Case ID] = EARLIER ( Table1[Case ID] ) )
)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Greg_Deckler
Community Champion
Community Champion

Perhaps something along the lines of:

 

Column = 
VAR __table = FILTER(ALL('Table6'),[CaseID]=EARLIER([CaseID]))
VAR __people = DISTINCT(SELECTCOLUMNS(__table,"__Name",[Name]))
VAR __distinct = DISTINCT(__people)
RETURN
COUNTX(__distinct,[__Name])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Users online (1,957)