Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

CONDITIONAL SUM

Hi Everyone:

I need some help with the set analysis i need to put this sum:

I have one field Enterprise, other field that is F/V and other that is Sales

All the enterprises has two values in F / V, what i need is to sum 3 enterprises with one value of F/V and the other 2 with the other diferent value in F/V, can anyone help me with this plz

4 Replies
johnw
Champion III
Champion III

I think you'll want to use the union operator (+) to get both sets of data in one aggregation (hopefully I got the syntax right):

sum({<Enterprise={A,B,C},"F/V"={A}>
+<Enterprise={D,E} ,"F/V"={B}>} Sales)

Though of course you could always do it by adding two sums, which might be more clear to most people:

sum({<Enterprise={A,B,C},"F/V"={A}>} Sales)
+ sum({<Enterprise={D,E} ,"F/V"={B}>} Sales)

Not applicable
Author

Thanks for your quick answer, but the issue in here is that the sum depends of what the user select, for example not always appears all the enterprises, it can be only A, or sometimes B,C,D, and the result must be in function of the client select, do i make myself clear???

johnw
Champion III
Champion III

I'm not sure I understood, but if you only want values that the client selected, you can use *= everywhere to intersect what the client selected with your expression. In other words:

sum({<Enterprise*={A,B,C},"F/V"*={A}>
+<Enterprise*={D,E} ,"F/V"*={B}>} Sales)

You could probably also do it by just intersecting $ with the union of your two sets. I honestly have no idea if QlikView lets you use parentheses to make compound sets like this, but maybe, and if it doesn't, it really should:

sum({$*(<Enterprise={A,B,C},"F/V"={A}>
+<Enterprise={D,E} ,"F/V"={B}>)} Sales)

Not applicable
Author

Thank you John It works very good thank you for your help