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: 
bbastro1106
Contributor III
Contributor III

Sum with 2 criteria

Hi All,

I am working on an expression to sum if 2 criteria match

Sum({$<[PO Total Units] = - {0}    ,  [PO Total Units]-[Original Units] < {0}     >} [PO Total Units]-[Original Units])

But it keep saying my expression is not correct

I break down the expression into 

Sum({$<[PO Total Units] = - {0}>} [PO Total Units]-[Original Units])

and 

Sum({$<[PO Total Units]-[Original Units] < {0} >} [PO Total Units]-[Original Units])

find the issue is came from 

Sum({$<[PO Total Units]-[Original Units] < {0} >} [PO Total Units]-[Original Units]).

Can anyone please help what syntax that i miss from the above formula?

 

1 Solution

Accepted Solutions
pradosh_thakur
Master II
Master II

Sum({$<[PO Total Units] = - {0} >}
if  ([PO Total Units]-[Original Units] < 0,  
 [PO Total Units]-[Original Units])
)
Learning never stops.

View solution in original post

3 Replies
pradosh_thakur
Master II
Master II

Sum({$<[PO Total Units] = - {0} >}
if  ([PO Total Units]-[Original Units] < 0,  
 [PO Total Units]-[Original Units])
)
Learning never stops.
bbastro1106
Contributor III
Contributor III
Author

Thanks! that works
bbastro1106
Contributor III
Contributor III
Author

I have a question regarding this expression.

This is a sum if expression for sure, but i do not understand why if is put under the second criteria when PO ttl until - original unit <0 and why AND is not necessary to include in the expression.

In expand of this expression, i am now trying to add one more criteria when perform the sum.

the third criteria will be (PO total units - original Unit)/Original Units >=0.05

In conclude this expression will sum up only if three criteria match.

With below expression, i try to add my third criteria like below, but I am not able to get my expected result.  It still show me the result with adding the third criteria. (additional expression are now underlying.

Sum({$<[PO Total Units] = - {0} >}
if ([PO Total Units]-[Original Units] < 0 AND
[PO Total Units]-[Original Units]/[Original Units] > 0.049
,
[PO Total Units]-[Original Units])
)

 

Hope someone can help.