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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Coolavin
Partner - Contributor III
Partner - Contributor III

Sum and count are not adding up.

I have a sum and a count that should be adding up to the same. but the sum has about 4,000 more records than the count.  See below:

=count( if({<[CredentialExpireDate] = {'<$(=Date(Today()))'}>}CredentialMeasure))

=Sum( if([CredentialExpireDate] < Date(Today()),1,0))

They both look at CredentialExpireDate and count or sum based on if CredentialExpireDate is less than today's date. I kow that the count is correct.

Is there a better way to do this?

 

5 Replies
Kushal_Chawda

What exactly your question is? If count expression is correct then why you are not using it?

Also, count expression seems to be wrong. it should be like below

=count( {<[CredentialExpireDate] = {"<$(=Date(Today()))"}>}CredentialMeasure)

TimvB
Creator II
Creator II

You should create an extra dimension to tag the 'Active' and 'Inactive' Credentials. Then use 'set analysis' to count or sum the total. See my previous comment:

https://community.qlik.com/t5/New-to-Qlik-Sense/Work-around-for-filters-and-empty-fields/m-p/1662699...

Coolavin
Partner - Contributor III
Partner - Contributor III
Author

Question is: why don't the sum and the count match? 

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I'm assuming you mis-typed the Count() expression, as it is invalid as you posted it. Assuming it's as @Kushal_Chawda corrected it, a difference would be that if() would include null CredentialDate, the set analysis would not. 

-Rob

Kushal_Chawda

There is difference between both the expression

Count expression specifically counts the CredentialMeasure wherever condition is met.

Catch here is, when CredentialMeasure don't have any value(Null) it will not be counted although condition is met while Sum expression will count it because in sum expression you are just flagging the 1 wherever condition is met. Hence, sum expression counting all the rows wherever condition is met whereas count expression just conts the rows where condition is met and CredentialMeasure is not null.