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: 
kstroupe
Creator
Creator

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

1 Solution

Accepted Solutions
kstroupe
Creator
Creator
Author

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

View solution in original post

6 Replies
tresesco
MVP
MVP

Have you tried like:

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

kstroupe
Creator
Creator
Author

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.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

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
Creator
Creator
Author

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))

Peter_Cammaert
Partner - Champion III
Partner - Champion III

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
Creator
Creator
Author

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