Skip to main content
Announcements
Qlik Community Office Hours, March 20th. Former Talend Community users, ask your questions live. SIGN UP
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Build a count function with two conditions

Hello ,

Can anybody can build an expression - function count names with two conditions :

first          A - B > 0

second     'Is it subject'= Yes

Thanks

M

1 Solution

Accepted Solutions
alex_millan
Creator III
Creator III

Maybe I didn't understand you well.

A, B and [Is it subject] are fields, right?

If so, I think this expression should work:

Sum(If(A-B>0 AND [Is it subject] = 'YES', 1, 0))

Let's see it it works

View solution in original post

7 Replies
alexandros17
Partner - Champion III
Partner - Champion III

The expression you are looking for is this:

Sum(If( Condition1 and Condition2, 1, 0)

is equivalemt to a count infact it sums 1 if both condition are satisfied

Hope it helps

Not applicable
Author

Thanks Alessandro,

I assumed It will be

Sum( If ( A - B > 0 and [Is it subject]= {Yes}, 1, 0)

but I am a new community member and I don't know where to put a 'name' which will be summed

MK_QSL
MVP
MVP

Sum( If ( (A - B) > 0 and [Is it subject]= {'Yes'}, 1, 0)

alex_millan
Creator III
Creator III

If [Is it subject] is a field name and Yes is the value,

you can try to set the second condition as [Is it subject] = 'Yes'

so the final syntax would be:

Sum(If A-B >0 And [Is it subject] = 'Yes',1,0)

Good luck!

Not applicable
Author

Thanks for answers ,

I build a functions but is error in expression and it no use .

Sum( If ( (-) > 0 and [Is it subject]= {'YES'}, 1, 0))

Could be an issue that A = one value + second  and the same B (C+D)

Does anybody have any idea ?

alex_millan
Creator III
Creator III

Maybe I didn't understand you well.

A, B and [Is it subject] are fields, right?

If so, I think this expression should work:

Sum(If(A-B>0 AND [Is it subject] = 'YES', 1, 0))

Let's see it it works

Not applicable
Author

Alex,

That's right  A, B  and [Is ... ] are fields

Your last answer was great !

Cheers M8