Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

kstroupe
Contributor

Count rows where two fields don't match

Hello,

I have data where I'm trying to count in a chart where two fields don't match.

Header 1Header 2Header 3Header 4Header 5Header 6
11HWHW414414
12HWSW414412

I would like to get a count of 1

Count (Header 1,Header 2) if Header 3 <> Header 4

I can make a flag at the table level and it works but when I try to put it in a Chart it fails.

Thanks

Kim

Tags (1)
1 Solution

Accepted Solutions
kstroupe
Contributor

Re: Count rows where two fields don't match

Thank you everyone...I solved my issue by adding a count flag to the load which was always 1.  and doing it this way.

sum(if(Header3 <> Header4, Aggr(Distinct(QTY),Header1 ,Header2)) )

I appreciate everyone's help and time on this.

Thanks

6 Replies
MVP
MVP

Re: Count rows where two fields don't match

Have you tried like:

=Count( if ([Header 3] <> [Header 4], [Header 2]))

kstroupe
Contributor

Re: Count rows where two fields don't match

Thank you for your response...I did try that and it worked as long as I was only counting Header 1, but I want to count dimension Header 1 and Header 2 concatenated together and it's at that point where my expression fails.

Re: Count rows where two fields don't match

In Clever's example, you are counting rows of an internal table that have Header3 <> Header4. That's the same as counting concatenated Header1 and Header2 values, unless you want to count distinct concatenated Header1 and Header2 value.

BTW to count occurrences of a composite field, perform a real concatenate like Header1 & Header2

kstroupe
Contributor

Re: Count rows where two fields don't match

Thank you... I am trying to count distinct because it is giving me a count of 2 where I would like a count of 1.  When I try to add the word DISTINCT I have an error in my expression.

=Count (if(Header3 <> Header4, Header1 & Header2))

Re: Count rows where two fields don't match

Are you asking me where the DISTINCT keyword goes? If so, see here: Count - chart function ‒ QlikView

It goes between the parentheses and in front of the current expression.

kstroupe
Contributor

Re: Count rows where two fields don't match

Thank you everyone...I solved my issue by adding a count flag to the load which was always 1.  and doing it this way.

sum(if(Header3 <> Header4, Aggr(Distinct(QTY),Header1 ,Header2)) )

I appreciate everyone's help and time on this.

Thanks