Announcements
cancel
Showing results for
Did you mean:
Partner - Creator

## Set Analysis - Aggr Function with If statement

Hi,

I have the following expression which works :

Sum(Aggr(Sum(NO_OF_TCKTS),WOFY,State,Store,Department))

I am trying to incorporate the below if statement into the above expression:

if(Sum({<Qlikdate4={'Mon'}>}NO_OF_TCKTS)/Sum(NO_OF_TCKTS)<0.02,1,0)

Any ideas?

Thanks

1 Solution

Accepted Solutions
Partner - Creator II

The rule of thumb is to have a single aggr(). I guess it would be something like:

Sum(Aggr(

if(Sum({<Qlikdate4={'Mon'}>}NO_OF_TCKTS)/Sum(NO_OF_TCKTS)<0.02,1,0)

,WOFY,State,Store,Department))

3 Replies
Creator II

Try to create a flag in the script like below

if(Sum(if(Qlikdate4='Mon',NO_OF_TCKTS))/Sum(NO_OF_TCKTS)<0.02,1,0) as flag

then use this as expression

Aggr(Sum(if(flag=1,1,0)),WOFY,State,Store,Department)

Partner - Creator II

The rule of thumb is to have a single aggr(). I guess it would be something like:

Sum(Aggr(

if(Sum({<Qlikdate4={'Mon'}>}NO_OF_TCKTS)/Sum(NO_OF_TCKTS)<0.02,1,0)

,WOFY,State,Store,Department))

Partner - Creator
Author

Thanks.