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
DemingPDCA
Helper I
Helper I

Distinct Count If Multiple Criteria

Not sure if I'm trying to do this the hard way, but I have a table has a row for each training a person goes through, I want to count the number of Yellow Belts, Green Belts and Black Belts, but don't want to double count. 

 

The Employee Name tells me the employee, the activity name tells me the training they went through. So the table looks like this:

 

User NameActivity Name
ADMAIC Yellow Belt Certification
ALean Yellow Belt Certification
ADMAIC Green Belt Certification
AABC Training
AXYZ Training
BLean Yellow Belt Certification
BABC Training
BXYZ Training

 

In the case above, I would want it to return the following Counts:
Yellow Belt Training = 2 (User A and B both went through at least 1 Yellow Belt Certification)

Green Belt Training = 1 (User A is the only one who has any Greenbelt Training).

 

I've been able to create a measure that shows Yellow Belt/Green Belt Certifications, but can't get them to Count/Sum and am not sure how to make sure they don't double count by user:

 

Yellow Belt Certification = CONTAINSSTRING(SELECTEDVALUE('Training Report'[Activity Name]), "Yellow")
Green Belt Certification = CONTAINSSTRING(SELECTEDVALUE('Training Report'[Activity Name]), "Green Belt Certification")

 

 

Screenshot below shows user ID instead of Employee Name mostly for privacy reasons - either can be used:

DemingPDCA_1-1671558595385.png

 

Table Set Up

DemingPDCA_2-1671558644921.png

 

 

1 ACCEPTED SOLUTION
Shaurya
Memorable Member
Memorable Member

Hi @DemingPDCA,

 

Create flags in your table for the different belts.

 

Yellow = IF(CONTAINSSTRING('Table (2)'[Activity Name],"Yellow Belt"),1,0)

 

Screenshot 2022-12-20 212841.jpg

 

Summarize this table to have count of individual belts for every person.

 

Result = SUMMARIZE('Table (2)','Table (2)'[User Name], "Yellow",SUM('Table (2)'[Yellow]), "Green",SUM('Table (2)'[Green]))

 

Now you can use the columns from this result table to create meaures that count and sum.

 

Yellow Count = CALCULATE(COUNT(Result[Yellow]),FILTER(Result,Result[Yellow]>0))

 

Works for you? Mark this post as a solution if it does!
Check out this blog of mine: How to Export Telemetry Data from Azure IoT Central into Power BI

 

View solution in original post

2 REPLIES 2
Shaurya
Memorable Member
Memorable Member

Hi @DemingPDCA,

 

Create flags in your table for the different belts.

 

Yellow = IF(CONTAINSSTRING('Table (2)'[Activity Name],"Yellow Belt"),1,0)

 

Screenshot 2022-12-20 212841.jpg

 

Summarize this table to have count of individual belts for every person.

 

Result = SUMMARIZE('Table (2)','Table (2)'[User Name], "Yellow",SUM('Table (2)'[Yellow]), "Green",SUM('Table (2)'[Green]))

 

Now you can use the columns from this result table to create meaures that count and sum.

 

Yellow Count = CALCULATE(COUNT(Result[Yellow]),FILTER(Result,Result[Yellow]>0))

 

Works for you? Mark this post as a solution if it does!
Check out this blog of mine: How to Export Telemetry Data from Azure IoT Central into Power BI

 

This worked great - thanks!

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.