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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Count Based on two columns

Hello,

I have a Table,

 

N_NameO_NameO_StatuspatID
AO1Completed8652
AO1Completed8652
AO1Completed8652
AO1Completed8718
AO1Completed8718
AO1Completed8718
AO2Completed 
AO2Completed 
AO2Completed 
AO3New 
AO4In Progress 
AO4In Progress 
BO5Completed8126
BO5Completed8126
BO5Completed8126
BO5Completed8126
BO5Completed8126
BO5New 

 

I wanted produce a table visualization which looks like the below,

 

dharanisrees_0-1654544718436.png

 

I wrote a dax query, 

count =  IF(ISNUMBER(DISTINCTCOUNT('Table'[PATID])),DISTINCTCOUNT('Table'[PATID]), 0)

 

But this produces a table like counting the null values of patID to be 1,

dharanisrees_1-1654544962738.png

 

Please help with correct dax query to avoid the above null values.

 

Thanks

 

 

 

2 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

This measure works

Count = coalesce(CALCULATE(DISTINCTCOUNT(Data[patID]),Data[patID]<>blank()),0)

Hope this helps.

Untitled.png


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

View solution in original post

Why have you used the ALL function there?  Try this measure

x_Applications Acted Upon = CALCULATE(DISTINCTCOUNT('Left Join'[LOANS.PAT_ID]), 'Left Join'[Application Status] == "Acted",'Left Join'[LOANS.PAT_ID]<>BLANK())


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

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thank you so much Sir

Ashish_Mathur
Super User
Super User

Hi,

This measure works

Count = coalesce(CALCULATE(DISTINCTCOUNT(Data[patID]),Data[patID]<>blank()),0)

Hope this helps.

Untitled.png


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

Sir, a quick question, 

How do i implement the same (i.e) avoiding the null values 

if my original dax query is something like the below,

 

x_Applications Acted Upon = CALCULATE(DISTINCTCOUNT('Left Join'[LOANS.PAT_ID]), FILTER(ALL('Left Join'[Application Status]), 'Left Join'[Application Status] == "Acted"))

Why have you used the ALL function there?  Try this measure

x_Applications Acted Upon = CALCULATE(DISTINCTCOUNT('Left Join'[LOANS.PAT_ID]), 'Left Join'[Application Status] == "Acted",'Left Join'[LOANS.PAT_ID]<>BLANK())


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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.