Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

magnusrydberg
New Contributor II

Error using sum and count together with Group By in Qlik script

Hi,

My problem is that I want to calculate unique users per day from a userlogfile "cacore.EnvUsersLog" and save this value in a new field "UUniqueUser"

My sqript is as follows:

// User Log

LOAD "UserId" as UUserId,

    LoginDate as ULoginDate,

    Year(LoginDate) as UYear,

    Week(LoginDate) as UWeek,

    dual( Year(LoginDate) & '-' & Week(LoginDate), num(Year(LoginDate)) & num(Week(LoginDate), '00' )) as UYearWeek,

    If(1=1,'Portal') as UType,

    dual( Year(LoginDate) & '-' & Month(LoginDate), num(Year(LoginDate)) & num(Month(LoginDate), '00' )) as UYearMonth,

  Sum(Count("UserId")) as UUniqueUser

  Group By LoginDate;

SQL SELECT *FROM "myloc_PROD_220".cacore.EnvUsersLog;


I got the following error message

Error in expression: Nested aggregation not allowed : LOAD "UserId" as UUserId, LoginDate as ULoginDate, Year(LoginDate) as UYear, Week(LoginDate) as UWeek, dual( Year(LoginDate) & '-' & Week(LoginDate), num(Year(LoginDate)) & num(Week(LoginDate), '00' )) as UYearWeek, If(1=1,'Portal') as UType, dual( Year(LoginDate) & '-' & Month(LoginDate), num(Year(LoginDate)) & num(Month(LoginDate), '00' )) as UYearMonth, Sum(Count("UserId")) as UUniqueUser Group By LoginDate


What am i doing wrong?

Thanks in advance!

// Magnus

Tags (3)
1 Solution

Accepted Solutions
poojashribanger
Contributor II

Re: Error using sum and count together with Group By in Qlik script

you acn't use nested aggregation like

Sum(Count("UserId")) as UUniqueUser


instead just use Count("UserId") you can sum it up in frontend.

2 Replies
poojashribanger
Contributor II

Re: Error using sum and count together with Group By in Qlik script

you acn't use nested aggregation like

Sum(Count("UserId")) as UUniqueUser


instead just use Count("UserId") you can sum it up in frontend.

magnusrydberg
New Contributor II

Re: Error using sum and count together with Group By in Qlik script

Thanks a lot! Sometimes it's more easier then you expect

Community Browser