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: 
jfelker88
Contributor
Contributor

Sum based on two conditions

Hello - I am trying to create a Sum expression based on two conditions - If Field A is distinct, and Field B is the same, sum the quantity. The example data set: 

MatchingMatching1Quantity
1234568038986-310.000
1234568038986-
1234568038986-
5678968038986-310.000
5678968038986-
5678968038986-
3456768038986-310.000
3456768038986-
3456768038986-
9876568038986-310.000
9876568038986-
9876568038986-
1029368038986310.000
1029368038986-
1029368038986-
2837468038986310.000
2837468038986-
2837468038986-
7456368038986310.000
7456368038986-
7456368038986-
5789368038986310.000
5789368038986-
5789368038986-

 

In this case,  take distinct Matching value and Matching1 = Matching1, then sum the quantity. Using these conditions you would get a net zero quantity with this example. 

I have the first part figured out, but not sure how to add the second condition where Matching1 is the same: 

sum(aggr(sum(DISTINCT [Quantity]), [Matching]))

Any help is appreciated. 

1 Reply
jochem_zw
Employee
Employee

Please try:

sum(aggr(sum(DISTINCT [Quantity]), [Matching],[Matching1]))