Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
AdrianoEllero
Contributor III
Contributor III

Conditional sum

Using this expression 
if(Material='abc',sum(Quantity),0)

I get the sum when the condition is respected.

I can't make it work if I add different items:

ex: if(Material='abc, 123, xyz',sum(Quantity),0)

 

if I use this kind of condition:

{<Material={'abc','123','xyz'}>}

sum(Quantity)

I get as expected only the sum of the filtered material 'abc','123','xyz'.
if the condition is not respected (the items are not found) I get the sum of all items, when I would expect as result 0.

Any hint or correction?

 

Labels (5)
1 Solution

Accepted Solutions
Nicolae_Alecu
Creator
Creator

Hello,

Try this: Sum(if(Match(Material,'abc','123','xyz'),Quantity,0)) 

And for the question from above, Match() evaluate true even if it find only one item.

Best Regards,

View solution in original post

4 Replies
BrunPierre
Partner - Master
Partner - Master

If(Match(Material,'abc','123','xyz'), Sum(Quantity), 0)

AdrianoEllero
Contributor III
Contributor III
Author

not working, does Match implicates that all items have to be found to execute the sum, or the sum will be executed if at least one item in the list will be found?

Nicolae_Alecu
Creator
Creator

Hello,

Try this: Sum(if(Match(Material,'abc','123','xyz'),Quantity,0)) 

And for the question from above, Match() evaluate true even if it find only one item.

Best Regards,

AdrianoEllero
Contributor III
Contributor III
Author

it works perfectly, thanks!