Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

cancel
Showing results for 
Search instead for 
Did you mean: 
leenlart
Creator
Creator

Count when the sum is greater than a variable

Hello, 

I'm trying to count clients that have made purchases over a target amount.  The target amount is in a variable: vINC1_VOL_MIN.  

I've whittled down my expression to the following , but it is returning a count for any client that has ordered any amount : 

count( aggr( sum({$<TYPE_CALENDRIER={'N'},ORIGIN={'FACTURES'}>} [TONNAGE VENDU]), %CLIENT_ID)>=$(vINC1_VOL_MIN) )

My control table looks like this, as you can see the first column (the formula above) is returning a 1 for all lines, regardless of the sum of sales.  

leenlart_0-1608227642977.png

Where do I need to put the condition so that the count takes it into ... account ?

Thanks so much for your help!!

Labels (4)
1 Solution

Accepted Solutions
lfholland
Creator
Creator

Try this:

count({<TYPE_CALENDRIER={'N'},ORIGIN={'FACTURES'}>}
distinct if(
aggr(sum({<TYPE_CALENDRIER={'N'},ORIGIN={'FACTURES'}>} [TONNAGE VENDU]), %CLIENT_ID)>=$(vINC1_VOL_MIN),
%CLIENT_ID))

View solution in original post

2 Replies
lfholland
Creator
Creator

Try this:

count({<TYPE_CALENDRIER={'N'},ORIGIN={'FACTURES'}>}
distinct if(
aggr(sum({<TYPE_CALENDRIER={'N'},ORIGIN={'FACTURES'}>} [TONNAGE VENDU]), %CLIENT_ID)>=$(vINC1_VOL_MIN),
%CLIENT_ID))

View solution in original post

leenlart
Creator
Creator
Author

Brilliant!

Thanks so much for your help!