Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Highlighted
Partner
Partner

My expression is not displaying the right results.

I have two fields Attendance and Defects. I am trying to count each 'Y' in both fields. The expression I wrote:

Count(IF(Attendance='Y', 1 AND Defects='Y',1))

It is not counting each 'Y' it seems to be ignoring the second 'Y' if it appears in the same row. I have included attachments below of my chart and my data model. In the attachment below I am supposed to have 6 Y not 5 Y.  Any help is appreciated.

1 Solution

Accepted Solutions
mov
Esteemed Contributor III

Re: My expression is not displaying the right results.

my mistyping:

count(if(Attendance='Y',1)) + count(if(Defects='Y',1))

7 Replies
mov
Esteemed Contributor III

Re: My expression is not displaying the right results.

Try

count(if(Attendance='Y',1) + count(if(Defects='Y',1)

Partner
Partner

Re: My expression is not displaying the right results.

It does not work. I actually tried that before but it gives me a '-'. Thanks for the reply though!

MVP
MVP

Re: My expression is not displaying the right results.

=Count(IF(Attendance='Y' AND Defects='Y', something))

mov
Esteemed Contributor III

Re: My expression is not displaying the right results.

my mistyping:

count(if(Attendance='Y',1)) + count(if(Defects='Y',1))

Partner
Partner

Re: My expression is not displaying the right results.

Massimo Grossi: That expression only counts the Y when both Attendance AND Defects =Y so in the Attachment above I only have 1 time where I have Y in both Attendance AND Defects so that's why I got '1' as a result from that expression. I want to count each 'Y' separate. Thanks for the reply though!

mov
Esteemed Contributor III

Re: My expression is not displaying the right results.

But this will return 5, not 6.  Unless I got the requirement wrong (?)

Partner
Partner

Re: My expression is not displaying the right results.

The expression you have written counts each individual 'Y', which is what I needed!! Thank you so much!!! This worked! I feel very silly though. I have been working on this for a while and it was right in front of me!