Announcements
cancel
Showing results for
Did you mean:
Contributor III

## Another Count Aggr question

Dear Qlik sense friends and wizards,

I need some help with  the following challenge.

I have order-data in which goods movements are coded. I'm trying to count the orders in which the qty of goods with a certain movement type  (202) exceed the qty of another movement type (551).

So far, this is what I have been able to come up with:
Count(Aggr(If(Count({\$<movement type={'202'}>}[qty])-Count({\$<movement type={'551'},[qty]>}distinct[Order])>'0', 1,0),Order))

I'm almost there, but I cannot figure out why the result also shows the orders where the qty's are equal and the orders where 551 exceeds 202.  (In the image, the orders in rows 69 and 80 should be excluded, but they're not.)

Help is appreciated.

Labels (1)
• ### Count Aggr If

1 Solution

Accepted Solutions
Partner - Champion

maybe this:
=Sum(
Aggr(
if( Count( {< movement type = {'202'} >} [qty] )
-
Count( {< movement type = {'551'} >} [qty] )
> 0, 1, 0 ), Order )
)

I hope it can helps.

2 Replies
Partner - Champion

maybe this:
=Sum(
Aggr(
if( Count( {< movement type = {'202'} >} [qty] )
-
Count( {< movement type = {'551'} >} [qty] )
> 0, 1, 0 ), Order )
)

I hope it can helps.

Contributor III
Author

Hi Agliotti,

This seems to do the trick.
I see you're using sum instead of count, but cannot figure out why.  Could you explain why my solution was wrong?