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
novotnajk
Resolver I
Resolver I

DISTINCT COUNT if Column A or Column B contain "X" value

Hi again, I have so many things to learn still with Power BI.  Appreciate any help on any of my outstanding questions.

Here is my next one...

 

I have three columns:

PATIENT ID

PRIMARY DIAGNOSIS

SECONDARY DIAGNOSIS

 

I'm trying to create a measure that counts distinct patients who have a particular diagnosis in either the PRIMARY or SECONDARY diagnoses columns.  For example:

 

PATIENT ID          PRIMARY DIAGNOSIS          SECONDARY DIAGNOSIS

123456789           Asthma                                 Diabetes

456789123           COPD                                    Asthma

741852963           Asthma                                 Cancer

963852741           Hypertension                        COPD

123456789           Influenza                               Asthma

 

I want to create a measure that says, Unique Asthmatics WHERE if PRIMARY DIAGNOSIS or SECONDARY DIAGNOSIS = "
Asthma, then = Unique Asthma Patient

 

From the above, I would expect my measure to say, "Unique Asthma Patients = 3

 

Help???!?!?!

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi,

You can create a measure as below:

 

Unique Asthma Patients = 
CALCULATE( DISTINCTCOUNT( Data[PATIENT_ID]),
FILTER( Data, Data[PRIMARY_DIAGNOSIS] = "Asthma" ||
Data[SECONDARY_DIAGNOSIS] = "Asthma"
)
)

result.PNG

 

Please accept this as a solution if it satisfies the requirement. Appreciate your Kudos. 🙂

 

Thanks.

View solution in original post

Awesome!  Thank you so much!  If you can help me with the other solutions, that would be great as well!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi,

You can create a measure as below:

 

Unique Asthma Patients = 
CALCULATE( DISTINCTCOUNT( Data[PATIENT_ID]),
FILTER( Data, Data[PRIMARY_DIAGNOSIS] = "Asthma" ||
Data[SECONDARY_DIAGNOSIS] = "Asthma"
)
)

result.PNG

 

Please accept this as a solution if it satisfies the requirement. Appreciate your Kudos. 🙂

 

Thanks.

Awesome!  Thank you so much!  If you can help me with the other solutions, that would be great as well!

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.