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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
kartiklal7
Frequent Visitor

Distinct Count with Filters

Hi All, 

 

From the data in the screenshot below I want to calculate the distinctcount of contactid when both Gen 113 and Gen 116 certifications are active for a contact. The answer for this set of data should be 2 but am I getting 0. Obviously I am doing something wrong. Please see my measure below. 

 

kartiklal7_2-1660142837364.png

Measure =
CALCULATE (
DISTINCTCOUNT ( 'Training Certification'[ContactId] ),
'Training Certification'[CertificationName] = "GEN 116 Software Assurance",
'Training Certification'[CertificationName] = "GEN 113 Mitel Performance Analytics",
'Training Certification'[IsActive] = TRUE
) + 0

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

Count gen 113 & 116 =
VAR gen113 =
    CALCULATETABLE (
        DISTINCT ( 'Training Certification'[Customer ID] ),
        'Training Certification'[CertificationName] = "GEN 113 Mitel Performance Analytics",
        'Training Certification'[IsActive] = TRUE
    )
VAR gen116 =
    CALCULATETABLE (
        DISTINCT ( 'Training Certification'[Customer ID] ),
        'Training Certification'[CertificationName] = "GEN 116 Software Assurance",
        'Training Certification'[IsActive] = TRUE
    )
RETURN
    COUNTROWS ( INTERSECT ( gen113, gen116 ) )

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

Try

Count gen 113 & 116 =
VAR gen113 =
    CALCULATETABLE (
        DISTINCT ( 'Training Certification'[Customer ID] ),
        'Training Certification'[CertificationName] = "GEN 113 Mitel Performance Analytics",
        'Training Certification'[IsActive] = TRUE
    )
VAR gen116 =
    CALCULATETABLE (
        DISTINCT ( 'Training Certification'[Customer ID] ),
        'Training Certification'[CertificationName] = "GEN 116 Software Assurance",
        'Training Certification'[IsActive] = TRUE
    )
RETURN
    COUNTROWS ( INTERSECT ( gen113, gen116 ) )

Thank you. This works perfectly. 

jcalheir
Solution Supplier
Solution Supplier

I could suggest you use the Filter function

 

 

CALCULATE (
    DISTINCTCOUNT ( 'Training Certification'[ContactId] ),
    FILTER(ALL(Training Certification[CertificationName]),
        'Training Certification'[CertificationName] = "GEN 116 Software Assurance" &&
        'Training Certification'[CertificationName] = "GEN 113 Mitel Performance Analytics" &&
        'Training Certification'[IsActive] = TRUE
    )
)

 

 

If it still doesn't work, try to drag the measure to your example table and debug the results

 

Kind regards,
José
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.