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
TimsLanding
Frequent Visitor

DAX Distinct Count of Count Rows Calculation

Hey All, 

 

   Having an issue when viewing qualified personnel. Some people have zero, they are indicated in a column as "No License", However when someone has a qualification, and for each of those qualifications, the same column will indicate "License". The issue I have when creating a measure, it counts all the times "License" is there, not simply the one time, so I can't give the answer to "How many people do we have with a license"

 

COMPANY      LAST NAME     LICENSE      QUALIFICATION

A                    Garth                License         Truck

A                    Garth                License         Van

B                    Vander              License         Truck

C                    Anders              No License 

D                    Dunn                License          Truck

D                    Clark                 License          Truck

D                    Clark                 License          Van



So when I do the Table using the Companies, and how many licensed personnel they have it should display

A       1

B       1

C       0

D       2

 

Any help is appreciated, I'm not sure how to use Distinct Count and Count Rows together, and using Filter doesn't seem to help either. 

1 ACCEPTED SOLUTION
Thejeswar
Resident Rockstar
Resident Rockstar

Hi @TimsLanding ,

You can try using the below DAX 

Create a Calculated Measure as shown below

NoofLicenses = 
VAR Licenses = CALCULATE(DISTINCTCOUNT(Table1[Last Name]), Table1[License] = "License") 
RETURN
IF(ISBLANK(Licenses), 0, Licenses)

 The Output looks as follows

Thejeswar_1-1674580209921.png

 

Regards,

View solution in original post

2 REPLIES 2
TimsLanding
Frequent Visitor

Thanks so much! I kept thinking I needed to use the Company in the equation, your equation works great!

Thejeswar
Resident Rockstar
Resident Rockstar

Hi @TimsLanding ,

You can try using the below DAX 

Create a Calculated Measure as shown below

NoofLicenses = 
VAR Licenses = CALCULATE(DISTINCTCOUNT(Table1[Last Name]), Table1[License] = "License") 
RETURN
IF(ISBLANK(Licenses), 0, Licenses)

 The Output looks as follows

Thejeswar_1-1674580209921.png

 

Regards,

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.