Announcements
cancel
Showing results for
Did you mean:
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(

DISTINCT Enrolment.EMPLID)

Labels (2)

• ### Set Analisys

1 Solution

Accepted Solutions

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])``
5 Replies
MVP

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

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") 😉

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])``

One more solution.

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

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

Community Browser