Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
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 (1)
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))

leenlart
Creator
Creator
Author

Brilliant!

Thanks so much for your help!