Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Logical and or with match

I hava a problem with the following code:

Load

name,

1 as _Flag

Where

  ( Match(COURSE ,'ENG2', 'ENG3') or Match(GRADE,'E', 'D','C', 'B','A' ))

  And (Match(COURSE,  'MATH5') or Match(GRADE, 'E', 'D','C', 'B','A' ))

Meaning that if a person attended both of the courses in English and got a valid grade and also attended the 'MATH5' class and got a valid grade in that course too then the Flag=1

I get to many records when I run the code above and not sure what I'm thinking wrong.

2 Replies
maxgro
MVP
MVP

from your question I think you only want the result in bold in my testdata

testdata:

load * inline [

name, COURSE, GRADE

m, ENG2, A

m, ENG3, A

m, MATH5, A

n, ENG2, A

n, ENG3, A

o, HIS, A

o, ENG3, A

o, MATH5, A

p, ENG2, F

p, ENG3, A

p, MATH5, A

];

result:

load name, if(NUM=3,1,0) as Flag;

load

  name,

  count(DISTINCT COURSE) as NUM

resident testdata

where match(COURSE, 'ENG2','ENG3','MATH5') and match(GRADE,'E', 'D','C', 'B','A' )

group by name;

1.png

Not applicable
Author

Thank's :-). That was the solution