Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
BARC’s The BI Survey 19 makes it official. BI users love Qlik. GET REPORT
cseward1963
Contributor

count (distinct if . . . . . .

Hello All.

This works for me:

count(distinct if (DC>0,studentid))    - count students who received direct or consult services

and this works too:

count(  distinct if ( (Ref>0) ,studentid  ))  - count students who were screened or evaluated

BUT, this does NOT work:


count(  distinct if ( (Ref>0) and (DC>0) ,studentid  ))  -  count students who were screened or evaluated and who received direct or consult services;  this expression always returns a ZERO 


7 Replies
galax_allu
Valued Contributor

Re: count (distinct if . . . . . .

count({<ref={‘>0’},DC={‘>0’} } studentid)


or



count(Distinct{<ref={‘>0’},DC={‘>0’} } studentid)

Partner
Partner

Re: count (distinct if . . . . . .

use set analysis instead

Count ({<ref={">0"},DC={">0"}>} distinct studentid)

zebhashmi
Valued Contributor

Re: count (distinct if . . . . . .

if I am recalling right. there is a Function AND() you would have to use.

Let me see if I can provide you a detail.

zebhashmi
Valued Contributor

Re: count (distinct if . . . . . .

count(  distinct if ( AND(Ref>0,DC>0) ,studentid  ))

or

count(  distinct if (Ref>0 and DC>0 ,studentid  ))

and May be this

count(  aggr(distinct if (Ref>0 and DC>0 ,studentid  )))

cseward1963
Contributor

Re: count (distinct if . . . . . .

Martin Pohl, thank you for your reply, your expression:

Count ({<ref={">0"},DC={">0"}>} distinct studentid)

is acceptable to the Editor, but it returns the same value as

count(distinct if (DC>0,studentid))

devarasu07
Honored Contributor II

Re: count (distinct if . . . . . .

Hi,

you can try below method,

Method 1: by creating cal. measure using set analysis

Count(distinct {$<Ref={">0"},DC={">0"}>} studentid

Method 2: by creating cal. measure using if condition

if(Ref>0 and DC>0, count(distinct studentid) )

Thanks,Deva

luismadriz
Valued Contributor

Re: count (distinct if . . . . . .

Hi,

Your expression should have worked, something else is happening.Yes, set analysis is better, but your expression should've worked,

Please share more information such as app, data, screenshots?

Cheers,

Luis