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
Antonio195754
Helper IV
Helper IV

Help creating logic to count and return name of missing courses

Hey all,

 

Not sure if this can be done but let me try and explain:  

 

I have a data set that has employee name in one column, training courses they have taken in another column, and whether courses are complete or not complete on what they've attempted in another column.  In total, every employee must complete 9 courses to be called 100% complete with their training.  The issue i'm having is the data only shows as mentioned earlier, what they've attempted to take, no matter if it's complete or not.  So some employees i may only see they have 5 courses next to their names (doesn't matter if it's complete or incomplete), and other employees i'll see all 9 courses (again doesn't matter if they're complete or not).  In a perfect world i would want to see all the courses, per employee and whether it's complete or not complete; unfortunately that's not the case. What i'm trying to do is, since i know the 9 course names, to find a way to make PBI call out which courses/names of courses are missing and the count of that variance.  How would i get this started?  I think i would have to make a seperate table of courses like below but being a novice in PBI, i wouldn't know how to write the DAX to say "If Employee A shows 7 courses taken in raw data, give me the count of what's missing and give me the names missing based on course name table"  And then find a way to roll that up so that it works for every employee (population of 5K~)

 

Please help!

 

Course 1
Course 2
Course 3
Course 4
Course 5
Course 6
Course 7
Course 8
Course 9
EmployeeCourseStatus
JoeCourse 1Complete
Joe

Course 2

Incomplete
JoeCourse 3Complete
JoeCourse 4Incomplete
JoeCourse 5Incomplete
JoeCourse 6Complete
JoeCourse 7Incomplete
MaryCourse 3Incomplete
MaryCourse 4Incomplete
2 ACCEPTED SOLUTIONS

@Antonio195754 

We can get something like this with just a few measures:

jdbuchanan71_0-1595956710610.png

This is the measure for Not Taken

Not Taken = 
VAR _x = VALUES ( Data[Course] )
VAR _y = CALCULATETABLE ( Courses, EXCEPT ( Courses, _x ) )
VAR _count  = COUNTROWS ( _y )
RETURN
IF ( 
    _count = 0 || NOT HASONEVALUE(Data[Employee]), BLANK(),
    "(" & _count & ") " &
    CONCATENATEX( _y, Courses[Course], ", ")
)

I have attached my sample file for you to look at.

 

View solution in original post

@Antonio195754 

If you return _count in the measure that should give you what you are looking for.

 

Incomplete 3 =
VAR _x1 =
    CALCULATETABLE (
        VALUES ( Compliance[COURSE_NAME] ),
        Compliance[COURSE_STATUS] = "Not Complete"
    )
VAR _x2 = VALUES ( Compliance[COURSE_NAME] )
VAR _y1 = CALCULATETABLE ( Courses, INTERSECT ( Courses, _x1 ) )
VAR _y2 = CALCULATETABLE ( Courses, EXCEPT ( Courses, _x2 ) )
VAR _y = UNION ( _y1, _y2 )
VAR _count = COUNTROWS ( _y )
RETURN
    _Count

View solution in original post

16 REPLIES 16

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.