intake class student_id
Sep 2022 - Eng English 100
Sep 2022 - Eng English 101
Nov 2022 - Sc Science 100
Jan 2023 - Bio Biology 101
Nov 2022 - Sc Science 102
Sep 2022 - Eng English 102
Jan 2023 - Bio Biology 102
Jan 2023 - Bio Biology 103
Jan 2023 - Bio Biology 105
Feb 2023 - Eng English 104
Feb 2023 - Eng English 103
Hello everyone,
I have a table as shown above. Each row in the table represent the student who is going to attend the classes. For example by looking at the Sep 2022 English class, I know that students with ID 100,101,102
are going to attend the class, and student 100,102
are going to attend Nov 2022 Science class, etc...
What I want to do is to transform the table into another format where it tells how many students did not attend or are not going to attend other classes among the students that are attending the class right now. The table below is the expected output:
I will show how to get the value in the table that are shown in the screenshot:
When student 100,101,102
are attending the Sep 2022 English class, among three of them:
101
) since only student 100,102
are in the list of science class;100
) since only student 101,102
are in the list
to attend biology class and student 100
is not in the list.Hence, for Sep 2022 - Eng intake:
When student 101,102,103,105
are attending the Jan 2023 Biology class, among 4 of them:
105
) since student 101,102
attended Sep 2022 English class and student 103
going to attend Feb 2023 English class;101,103,105
) since only student 102
are in the list of science class;Hence, for Jan 2023 - Bio intake:
I have been struggled to transform the data into the desired format like what I show in the screenshot. In fact, I'm not sure whether it is possible to do it or not using powerquery or DAX. Any help or advise will be greatly appreciated. Let me know if my question is not clear.
Add 3 measures to a table as follows:
no_science =
VAR ids = VALUES('Table'[student_id])
VAR ids_sci = CALCULATETABLE(VALUES( 'Table'[student_id]), REMOVEFILTERS('Table'), 'Table'[class] = "Science")
RETURN COUNTX( EXCEPT(ids, ids_sci), 'Table'[student_id])+0
no_english =
VAR ids = VALUES('Table'[student_id])
VAR ids_eng = CALCULATETABLE(VALUES( 'Table'[student_id]), REMOVEFILTERS('Table'), 'Table'[class] = "English")
RETURN COUNTX( EXCEPT(ids, ids_eng), 'Table'[student_id])+0
no_biology =
VAR ids = VALUES('Table'[student_id])
VAR ids_bio = CALCULATETABLE(VALUES( 'Table'[student_id]), REMOVEFILTERS('Table'), 'Table'[class] = "Biology")
RETURN COUNTX( EXCEPT(ids, ids_bio), 'Table'[student_id])+0