Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count if Sum(x)> 5000

Hi,

I am trying to write an expression where I want to calculate the number of distinct PO's with Line Amount less than or equal to $5000.

I believe I need to Aggregate the [Line Amount] spend by [PO Number] to list all such PO's in straight table.

I'd appreciate if I could get the best method/syntax to produce this result?

Thank you in advance.

1 Solution

Accepted Solutions
MarcoWedel

=-Sum(Aggr(Sum([Line Amount]), [PO Number])>5000 and Aggr(Sum([Line Amount]), [PO Number])<=10000)

QlikCommunity_Thread_132436_Pic9.JPG.jpg

QlikCommunity_Thread_132436_Pic10.JPG.jpg

please mark helpful / correct whatever answer helped you solve your problem.

thanks

hope this helps

regards

Marco

View solution in original post

16 Replies
NickHoff
Specialist
Specialist

Try set analysis:

=COUNT({$<LineAmount <= {'5000'}>}DISTINCT PO)

Not applicable
Author

Nick, thanks for the response. Maybe I wasnt clear! Each PO can have multiple Line Amounts against it.

I need to sum all Line Amounts for a PO number.

And then apply the <=5000 condition to count all PO's with spend greater than 5000.

Hope this helps.

Thank you!

maxgro
MVP
MVP

count( {$<LineAmount = {“<=5000”}>} distinct PO)

NickHoff
Specialist
Specialist

=SUM(AGGR(DISTINCT PO)({$<LineAmounts = {'<=5000'}>}LineAmounts)

JonnyPoole
Employee
Employee

I think this would work where [PO] is your field that denotes a unique PO. 

count( DISTINCT  if (  aggr(sum([Line Amount) , [PO] ) > 5000, [PO]))

MarcoWedel

Hi,

one possible solution:

=-Sum(Aggr(Sum([Line Amount]), [PO Number])<=5000)

QlikCommunity_Thread_132436_Pic1.JPG.jpg

QlikCommunity_Thread_132436_Pic7.JPG.jpg

QlikCommunity_Thread_132436_Pic5.JPG.jpg

QlikCommunity_Thread_132436_Pic6.JPG.jpg

QlikCommunity_Thread_132436_Pic2.JPG.jpg

QlikCommunity_Thread_132436_Pic3.JPG.jpg

QlikCommunity_Thread_132436_Pic4.JPG.jpg

QlikCommunity_Thread_132436_Pic8.JPG.jpg

tabLineAmounts:

LOAD Chr(64+RecNo()) as [PO Number],

     Ceil(Rand()*100) as [Line Amount]

AutoGenerate 10

While IterNo() <= 98;

hope this helps

regards

Marco

Not applicable
Author

Marco,

Thank you for the response. Could you also guide me how might I able to do the same thing for a range.

Example: Count of all PO's where Sum(Line Amount) is greater than $5000 and less than/equal to $10,000.

Thank you and appreciate your help.@

MarcoWedel

=-Sum(Aggr(Sum([Line Amount]), [PO Number])>5000 and Aggr(Sum([Line Amount]), [PO Number])<=10000)

QlikCommunity_Thread_132436_Pic9.JPG.jpg

QlikCommunity_Thread_132436_Pic10.JPG.jpg

please mark helpful / correct whatever answer helped you solve your problem.

thanks

hope this helps

regards

Marco

Not applicable
Author

Marco,

Thank you for your help! My data does not seem to tie... Can you help me with below:

1) My numbers are not tying up. Is there a way I can modify the set expression to exclude all records where [PO Number] is blank?

2)Can you also help me with finding the total dollar value of all such PO's.

Example: I want to find the total dollar value of the 5 PO's that have spend between 5000 and 10000

Thank you for your help!

Regards,

Deep