# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Support Cases coming to Qlik Community Oct. 4! Start chats, open cases, explore resources: READ DETAILS
cancel
Showing results for
Did you mean:
Creator

## Sum Aggr Sum with multiple set analysis query

Hi all,

I have an expression where I need to use multiple set analysis criteria. A simplified version is below

Sum({<Set Analysis Criteria 1>} Aggr (Sum {<Set Analysis Criteria 1>}  Sales), Division))

+

Sum({<Set Analysis Criteria 2>} Aggr (Sum {<Set Analysis Criteria 2>}  Sales), Division))

I was hoping and expecting that I could combine them into a simpler version, e.g.

Sum({<Set Analysis Criteria 1>+<Set Analysis Criteria 2>}

Aggr (

Sum {<Set Analysis Criteria 1>+<Set Analysis Criteria 2>}  Sales), Division))

but this isnt giving me the same answer.

Does it not work like this? Or is it not working in mine becuse of the set analysis criteria I am using?

I would be grateful of any help.

Also, as a side question, do I necessary need the same Set analysis criteria after both "sums" in a sum-aggr-sum expression?

1 Solution

Accepted Solutions
MVP

Another way to do this would be (not that it would be any better)

Sum(Aggr(

RangeSum(Sum({<Transaction_Type={'C'}>}Value),

-Sum({<Transaction_Type={'C'}, Customer_Name={'Void'}>}Value),

-Sum({<Transaction_Type={'C'}, Customer_Type={2}, Customer_Name={'*'}-{'Void'}>}Value))

, CustomerID, Week))

8 Replies
MVP

Not always are they going to work... if the set analysis overlap, the sum from the two expressions can overlap and the two expressions can give you very different numbers.

Please post full metric to check

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Creator
Author

My real expression is something more like

Sum ({<Transaction_Type={'C'}>}

Aggr (Sum {<Transaction_Type={'C'}>}Value), CustomerID, Week))

-

Sum ({<Transaction_Type={'C'},  Customer_Name={'Void'}>}

Aggr (Sum {<Transaction_Type={'C'}, Customer_Name={'Void'}>}Value), CustomerID, Week))

-

Sum ({<Transaction_Type={'C'}, Customer_Type={2}, Customer_Name={'*'}-{'Void'}>}

Aggr (Sum {<Transaction_Type={'C'}, Customer_Type={2}, Customer_Name={'*'}-{'Void'}>}Value), CustomerID, Week))

So, its a case of

Show me the sum off all C transactions

Less all C transactions for Voids

Less all C transactions for Type 2 customers except Voids (as they have been excluded above)

If someone can show me a better / cleaner way of writing that, I would appreciate it

MVP

Another way to do this would be (not that it would be any better)

Sum(Aggr(

RangeSum(Sum({<Transaction_Type={'C'}>}Value),

-Sum({<Transaction_Type={'C'}, Customer_Name={'Void'}>}Value),

-Sum({<Transaction_Type={'C'}, Customer_Type={2}, Customer_Name={'*'}-{'Void'}>}Value))

, CustomerID, Week))

Master II

in which object you are using the expression ? as you are using aggr(sum() it must be a text box.

 Karl Hart wrote: So, its a case of Show me the sum off all C transactions Less all C transactions for Voids Less all C transactions for Type 2 customers except Voids (as they have been excluded above) If someone can show me a better / cleaner way of writing that, I would appreciate it

when you said less all you meant diffrence or exclusion ? if exclusion and i understood it correctly than you dont need a complex expression.

Learning never stops.
Master

HI,

try this

Sum(

Aggr(

Sum ( {<Transaction_Type={'C'} ,  Customer_Type-={2} , Customer_Name-={'Void'}>} Value)

, CustomerID, Week

)

)

Creator
Author

Thanks, that has worked and reduced the calculation time - which is what I was trying to achieve with this

Creator
Author

Thank you, I did think about this after I posted the question, but there is another criteria which I didnt include which means there is some overlapping and so this wouldnt work in my case

Community Browser