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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

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
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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