Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
We are aware of an issue with the Product Downloads page and looking into it.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Aggregation Query

Hi,

I am trying to Aggregate a sample set of data. It looks something like;

    

MarksSemesterStudentSubject
801BEco
801BEnglish
801AEco
801AEnglish
801AMaths
1001AMain_Eco
1001AMain_English
1001AMain_Maths

The Requirement is to aggregate the set by Student such that any student ,if has at least one subject starting with'Main' , then the result should be Yes, else No, .Hence Student 'A' should be "Yes' and B be 'No'

I tried with the below expression, but the problem is it gives 'No' for Student 'A' with Non-Main subject row,

     if((Left(Subject,4)='Main')  ,If(Aggr(Sum(Marks), Student)>0,'Yes'),'No')

The result should look something like :

 

StudentSubjectSemesterAggr
BEco1No
BEnglish1No
AEco1Yes
AEnglish1Yes
AMain_Maths1Yes
AMaths1Yes

Appreciate any help !

Thanks

Labels (1)
1 Solution

Accepted Solutions
MarcoWedel
MVP
MVP

Hi,

another solution could be:

=If(Max(TOTAL<Student> WildMatch(Subject,'Main*')),'Yes','No')

QlikCommunity_Thread_170286_Pic1.JPG

hope this helps

regards

Marco

View solution in original post

6 Replies
sunny_talwar
MVP
MVP

Try this:

If(WildMatch(Aggr(NODISTINCT Concat(DISTINCT Subject), Student), '*Main*'), 'Yes', 'No')

Output:

Capture.PNG

sunny_talwar
MVP
MVP

Not sure if you need the second condition for any reason, you can add that in there too:

If(WildMatch(Aggr(NODISTINCT Concat(DISTINCT Subject), Student), '*Main*') and Aggr(NODISTINCT Sum(Marks), Student) > 0, 'Yes', 'No')

maxgro
MVP
MVP

if(max(TOTAL <Student> aggr(count({$ <Subject={"Main*"}>} Subject), Student, Subject, Semester))>0, 'yes', 'no')

MarcoWedel
MVP
MVP

Hi,

another solution could be:

=If(Max(TOTAL<Student> WildMatch(Subject,'Main*')),'Yes','No')

QlikCommunity_Thread_170286_Pic1.JPG

hope this helps

regards

Marco

MarcoWedel
MVP
MVP

or

=If(Min(TOTAL<Student> Subject like 'Main*'),'Yes','No')

hope this helps

regards

Marco

Not applicable
Author

Thanks Marco !