Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Why does aggr() work fine around COUNT() - but not around SUM()

Hi,

I wonder if there is any simple answer to this:

- In all of my apps, there is a chart "presence_quota" which is always the same - well, mostly:

     - The HR_app has a formula with COUNT() to calculate the nr. of employees

     - all others have a formula with SUM()

      => I guess I did not have the time to make them all equal as it does of course require some work in the script.

Now, in my HR_app, when one changes the dimension from day to month, there is a copy of the formula with aggr() - so it's aggr(Count([something]))

<=> in all the other apps, that didn't work, the figures are wrong as yet, so I developed a code to determine the nr. of workdays in any month and divide the total sum() by that. That then is a pretty good approximation.

<=> In the HR_app, on the other hand, that approach doesn't work at all.

The only thing I can imagine right now is that it has to do with the difference of Count() vs. Sum().

Can anybody explain that to me? Is there any general principle for this?

Thanks a lot!

Best regards,

DataNibbler

3 Replies
Anonymous
Not applicable

What is it you Count() / Sum() ?

Does it always have a value of 1 ?

Are there any nulls, space, zero's anything else ?

marcus_sommer

Hi DataNibbler,

perhaps you counted over a key-field or it missed a distinct-statement or something like that? Then I couldn't imagine that there is a general difference between count and sum ...

- Marcus

datanibbler
Champion
Champion
Author

Hi all,

there is the personell_number. The difference is merely that

- in the HR_app, I count that directly (on the GUI) - don't ask me why, I guess I didn't find the time to adapt it to all the other 
   apps ...

- in all other apps, I count it in the script, aggregate the table by certain categories - and on the GUI I merely sum up

   those COUNTs.

I will try that out when I find the time.

The more important question/ issue with this KPI is something else. But in order to not make it too confusing for others looking at this, I will open a new thread for that.

Best regards,

DataNibbler