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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
jood_ahmad
Creator II
Creator II

It Possible to do Sum inside Count AGGR Function

HI All ,

it is possible to do Sum Inside Count Aggr function

COUNT(AGGR(Sum({<  ITEM_GROUP={[XXXXX]} >},QUANTITY)), %Order_Key)

what is wrong in my formula .

Message was edited by: Ahmad Kastero

16 Replies
swuehl
MVP
MVP

Remove the comma before QUANTITY and move a bracket to the end:

=COUNT(AGGR(Sum({<  ITEM_GROUP={[XXXXX]} >} QUANTITY), %Order_Key))

But I am not sure what you want to achieve with this expression, counting a sum?

edit:

Another question: what do you want to achieve with this set modifier:

ITEM_GROUP={[XXXXX]}


if you want to do a record based field value comparison,you are probably better off with


=COUNT(AGGR( Sum(If( ITEM_GROUP=[XXXXX], QUANTITY)), %Order_Key))

Chanty4u
MVP
MVP

did u try outside it

AGGR(count(Sum({<  ITEM_GROUP={[XXXXX]} >},QUANTITY)), %Order_Key)

jood_ahmad
Creator II
Creator II
Author

i have to build a report with this :

first of all i have an Orders and this Orders are contain Items like X,Y, Z ; i need to know how many orders that have Quantity from (X) if Sum of X are =1 and how many orders that have quantity  from (X) if the Sum of X are = 2

and the quantity are inserted to my DB by number 1;

so i need first to get the sum for each item group after that count the orders that meet my condition.

i hope this will clarify and clear .

Kushal_Chawda

Still not clear what you are trying to achieve, can you try this

=count({<%Order_Key={"=sum({<ITEM_GROUP={[XXXXX]}>}QUANTITY)>0"} >}%Order_Key)

if not help then please post some sample data with required output

jood_ahmad
Creator II
Creator II
Author

unfortunately this is not working i will upload a sample.

jood_ahmad
Creator II
Creator II
Author

unfortunately this is not working i will upload a sample.

Kushal_Chawda

This? according to your sample

jood_ahmad
Creator II
Creator II
Author

what formula you use for this.?

sunny_talwar

I am getting a slightly different output then urs Kush.

I got 55105, 41114 and 75684 using these expressions

1)=Sum(Aggr(If(Count({<ITEM_FAMILY_GROUP = {'Large Pizza'}>} %Order_Key) = 1, 1, 0), %Order_Key))

2)=Sum(Aggr(If(Count({<ITEM_FAMILY_GROUP = {'Large Pizza'}>} %Order_Key) = 2, 1, 0), %Order_Key))

3)=Sum(Aggr(If(Count({<ITEM_FAMILY_GROUP = {'Large Pizza'}>} %Order_Key) >= 2, 1, 0), %Order_Key))