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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
bigmike7
Contributor II
Contributor II

Quick Aggr Question= Count number of customers with sales of product

Trying to figure out how to show the number of distinct customers that have sales in a given period of time

I think it would be something like to following but it this is returning a 1 instead of a count:

=

aggr(if(sum({$<$MONTH_INDEX={">=$(=vTimeCEnd-11)<=$(=vTimeCEnd-0)"},PRODUCT_GROUP={'KeyProduct'}>} Sales)>=1,1,0), CUSTOMER_ID)

1 Solution

Accepted Solutions
sunny_talwar

May be you need to add Sum()

Sum({$<$MONTH_INDEX={">=$(=vTimeCEnd-11)<=$(=vTimeCEnd-0)"},PRODUCT_GROUP={'KeyProduct'}>}


aggr(if(sum({$<$MONTH_INDEX={">=$(=vTimeCEnd-11)<=$(=vTimeCEnd-0)"},PRODUCT_GROUP={'KeyProduct'}>} Sales)>=1,1,0), CUSTOMER_ID)

)

View solution in original post

2 Replies
sunny_talwar

May be you need to add Sum()

Sum({$<$MONTH_INDEX={">=$(=vTimeCEnd-11)<=$(=vTimeCEnd-0)"},PRODUCT_GROUP={'KeyProduct'}>}


aggr(if(sum({$<$MONTH_INDEX={">=$(=vTimeCEnd-11)<=$(=vTimeCEnd-0)"},PRODUCT_GROUP={'KeyProduct'}>} Sales)>=1,1,0), CUSTOMER_ID)

)

daveamz
Partner - Creator III
Partner - Creator III

Hi Michael,

Are you trying to use that expression as a dimension? If not, you don't really need the Aggr()

Try this in a text box:

=Count(DISTINCT {<CUSTOMER_ID={"=Sum({<MONTH_INDEX={"">=$(=vTimeCEnd-11)<=$(=vTimeCEnd-0)""}, PRODUCT_GROUP={'KeyProduct'}>} Sales)>0"}>} CUSTOMER_ID)

Please be aware that this nested set analysis can be very slow depending on the data set.

Regards,

David