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
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
Super User
Super User

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])

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.