Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

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

Re: Build a count function with two conditions

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

7 Replies

Re: Build a count function with two conditions

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

Re: Build a count function with two conditions

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

Re: Build a count function with two conditions

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

alex_millan
Contributor III

Re: Build a count function with two conditions

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

Re: Build a count function with two conditions

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

Re: Build a count function with two conditions

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

Re: Build a count function with two conditions

Alex,

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

Your last answer was great !

Cheers M8

Community Browser