Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
We value your feedback – take our 5-minute QlikView modernization survey
cancel
Showing results for 
Search instead for 
Did you mean: 
varunvarma
Contributor III
Contributor III

Need count who attended only Maths

 

Hi Team,

I need to count of Students who attended only Maths. Please find the sample data below.

load * inline [

StudentId,Subject

1, Maths

1, Physics

2, Maths

2, Chemistry 

3, Physics

3, Maths

4, Maths

5, Chemistry

6, Maths

]

Result : Count of StudentId who attended only Maths - ie 2.

I need to achieve this in text object, only with set Analysis or If condition. No change in data model.

please let me know if you got any idea. Thanks in advance.

Labels (2)
1 Solution

Accepted Solutions
rubenmarin

Hi, you can try this expression:
=Count({<Subject = {'Maths'}, StudentId={"=Count(Distinct Subject)=1"}>} StudentId)

View solution in original post

5 Replies
Anil_Babu_Samineni

Try this?
Count({<Subject = {'Maths'}>} StudentId)
Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
varunvarma
Contributor III
Contributor III
Author

Hi, I need only count of StudentId who attended only Maths. Ie result should be 2. 

StudentId : 4 and 6. Only these 2 students attended only Maths.

rubenmarin

Hi, you can try this expression:
=Count({<Subject = {'Maths'}, StudentId={"=Count(Distinct Subject)=1"}>} StudentId)
varunvarma
Contributor III
Contributor III
Author

@rubenmarin Thanks for the support. It’s working fine. 

But 1 doubt, how count of distinct subject are aggregated by student only. In case if I have multiple columns then how it behaves. 

rubenmarin

Hi, I don't underestand the problem with multiple columns, can you expand the question with sample data?

The expresion works with 2 conditions: having Maths as subject and having only one subject, so this only subject has to be Maths to be counted.