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

Intersection between 2 values

Hey guys,

I have the below dataset:

Student ID, Semester

1, A
2, A
2, B
3, B

I am using the below expression to give me the count of the common items which should be 1 since only student 2 attened semester A & B. But it is giving me 4. Can someone help please?

=Count(

{1<Semester=,[Academic Year]=,SemesterNO={'$(=max(SemesterNO))'}> +
1<Semester=,[Academic Year]=,SemesterNO={'$(=max(SemesterNO)+100)'}>}
DISTINCT Enrolment.EMPLID)

Labels (2)
1 Solution

Accepted Solutions
Saravanan_Desingh

To get the value:

=Only({<[Student ID]=p({<Semester={'A'}>})*p({<Semester={'B'}>})>}[Student ID])

To get the count:

=Count(DISTINCT {<[Student ID]=p({<Semester={'A'}>})*p({<Semester={'B'}>})>}[Student ID])

View solution in original post

5 Replies
Or
MVP
MVP

You seem to be using the '+' operator, which is union, rather than the '*' modifier for intersect.

Taoufiq_Zarra

@Edge 

can you share a sample data

SemesterNO ? Academic Year ? Semester ?

what is the expected output ? from this output :

Student ID, Semester

1, A
2, A
2, B
3, B

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Saravanan_Desingh

To get the value:

=Only({<[Student ID]=p({<Semester={'A'}>})*p({<Semester={'B'}>})>}[Student ID])

To get the count:

=Count(DISTINCT {<[Student ID]=p({<Semester={'A'}>})*p({<Semester={'B'}>})>}[Student ID])
Saravanan_Desingh

One more solution.

=Count(DISTINCT{<[Student ID]={"=Concat(DISTINCT Semester)='AB'"}>}[Student ID])
Edge
Creator
Creator
Author

Thanks to all who responded and provided solutions :). Really appreciate the amazing qlik community.