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
Anonymous
Not applicable

Distinct count "file no's" grouped by "client id"

Dear community!

 

I hope you can help me. I need to calculate the unique occurences of 'DECISION_NO' grouped by 'CLIENT_ID'. What I ultimately want to achieve is to calculate whether a client is "recurring". I think I can do this by subtracting the number of distinct 'DECISION_NO' from the number of times a 'CLIENT_ID' occurs in the dataset. If this number is more than 0, the client is recurring (see the column 'RETURNING_CLIENT' in mock data below)

 

I have managed 'count_ID' as a calculated column, but I struggle with 'count_decision': The number of distinct 'DECISION_NO' grouped by 'CLIENT_ID'

 

Some context with the dataset

I have a dataset where every individual record refers to a 'CARE PRODUCT'. These care products are tied to decisions and files. 

A client can be linked to multiple files (minimum of 1);

A file can be linked to multiple decisions (minimum of 1) and products (minimum of 1)

 

So if there is a client in the dataset, there is at least 1 file_no and 1 decision_no.

 

I hope you people can help me out.

 

CLIENT_IDFILE_NODECISION_NOSTART_CAREEND_CARECARE_PRODUCTcount_IDcount_decisionreturning_CLIENT
100201101-1-20181-2-2018A1431
100201101-1-20181-2-2018B2431
100202111-4-20181-5-2018A2431
1002021212-4-20181-6-2018B2431
125305361-5-20181-7-2018C1110
135307441-7-20181-8-2018A3220
135307441-7-20181-8-2018B1220
140333511-8-20181-9-2018A1321
140333511-8-20181-9-2018B2321
140333521-8-20181-10-2018C2321
1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

=CALCULATE(DISTINCTCOUNT(Data[DECISION_NO]),FILTER(Data,Data[CLIENT_ID]=EARLIER(Data[CLIENT_ID])))

For Client ID 35 the answer should be 1.

Hope this helps.


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

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

=CALCULATE(DISTINCTCOUNT(Data[DECISION_NO]),FILTER(Data,Data[CLIENT_ID]=EARLIER(Data[CLIENT_ID])))

For Client ID 35 the answer should be 1.

Hope this helps.


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

Thanks! This works! I have accepted your answer as the solution.

You are welcome.


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

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.