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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Aksh_1234
New Member

Unable to get count of students who have submitted all assignments using DAX

Hi All,

 

I have a table in which there are multiple entries of some students and what is the status of their subjects whether they have submitted the assignments or not.

And I have a dim table for all the subjects from which I can do DISTINCTCOUNT to check the total number of subjects/assignments. Now,  I want to find out the number of students who have completed all the assignment. 

 

Table looks like this:

StudentNameAssignmentStatus
s1assignment1completed
s2assignment1

completed

s2assignment2pending
s3assignment1completed
s3assignment2

completed

 

Lets say that we only have two assignments in the dim table. Now, if we see the example above, only student3 have completed both the assignments. So, my final measure should give the result as 1 as only one student has completed all assignments. This is just an example subset of data.

 

The measure, that I am using is -

Students Completed =
VAR StudentwiseAssignmentSubmitted =
SUMMARIZE (
'Table',
'Table'[StudentName],
"SubmittedAssignmentCount",
CALCULATE (
DISTINCTCOUNT ( 'Table'[Assignment] ),
FILTER ( 'Table', 'Table'[Status] = "Completed" )
)
)
VAR TotalAssignments =
DISTINCTCOUNT ( dimAssignment[AssignmentName] )
RETURN
CALCULATE (
COUNTROWS ( StudentwiseAssignmentSubmitted ),
FILTER (
StudentwiseAssignmentSubmitted,
[SubmittedAssignmentCount] = TotalAssignments
)
)
But somehow this measure is always giving me total number of students present in the table. Tried various approaches but not getting the correct answer
 
Can anybody please help where it is going wrong?
 
Regards
2 REPLIES 2
HotChilli
Super User
Super User

Remove everything in the RETURN statement and replace it with :

COUNTROWS ( FILTER (StudentwiseAssignmentSubmitted, [SubmittedAssignmentCount] = _TotalAssignments) )

Hey, It worked. Thanks a lot. Could you please explain why it was not working earlier, because as per my understanding that is also the same thing.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors