Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
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
Partner Ambassador
Partner Ambassador

Please try:

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