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
Mahdi1366
Regular Visitor

How to Count Users with Multiple Mourse Completions?

Hi team,

 

I need to count people who are compliant with all courses that our company offers to them. Anyone who completes all courses is compliant, others are not. 

For example, let's say we have 5 courses for 4 users, and the first three courses are requirements to become compliant. How should I code it?

Mahdi1366_0-1669335894703.png

Sorry, if it's an easy question. I can think of it in an algorithmic way, but not sure how to write it in DAX. Appreciate your suggestions. 

1 ACCEPTED SOLUTION

First, create a calculated column

Count = 
IF ( 'Table'[Course] IN { "C1", "C2", "C2" } && 'Table'[Completed] = "No", 1 )

 

Then create this measure:

Compliant = 
SUMX (
    SUMMARIZE (
        'Table',
        'Table'[Name],
        "CountNo",
            CALCULATE (
                 sum('Table'[Count]),
                ALLEXCEPT ( 'Table', 'Table'[Name] )
                
            )
    ),
    IF ( [CountNo] = BLANK (), 1 )
)

 

danextian_0-1669360269867.png

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

5 REPLIES 5
Mahdi1366
Regular Visitor

Thank you @danextian, but it's not working. 

It returns Blank. 

I was expecting the code to count the YESs and distinct-count every name that is equal to 3 (in this example). With the filter on C4 and C5 that are irrelevant courses.

Hi @Mahdi1366 ,

 

My understanding is any [Name] that has [Completed] = No is non-compliant so if count of no of a name is blank, should be compliant.  The  original logic showed  the total on a per name basis but not as a whole. Please try this instead.

Compliant =
SUMX (
    SUMMARIZE (
        'Table',
        'Table'[Name],
        "CountNo",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                ALLEXCEPT ( 'Table', 'Table'[Name] ),
                'Table'[Completed] = "No"
            )
    ),
    IF ( [CountNo] = BLANK (), 1 )
)

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian You could be right that every [name] with [completed] = No is non-compliant IF there were no irrelevant courses. In the above example, Name A is compliant although A has not completed course C4. 
* To be compliant, you only need to complete C1, C2, and C3.

First, create a calculated column

Count = 
IF ( 'Table'[Course] IN { "C1", "C2", "C2" } && 'Table'[Completed] = "No", 1 )

 

Then create this measure:

Compliant = 
SUMX (
    SUMMARIZE (
        'Table',
        'Table'[Name],
        "CountNo",
            CALCULATE (
                 sum('Table'[Count]),
                ALLEXCEPT ( 'Table', 'Table'[Name] )
                
            )
    ),
    IF ( [CountNo] = BLANK (), 1 )
)

 

danextian_0-1669360269867.png

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
danextian
Super User
Super User

Hi @Mahdi1366 ,

 

Try this:

 

Compliant =
VAR CountOfNo =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        ALLEXCEPT ( 'Table', 'Table'[Name] ),
        'Table'[Completed] = "No"
    )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Name] ),
        FILTER ( 'Table', CountOfNo = BLANK () )
    )









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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.