IF (A > 0, count (DISTINCT B))
If Variable A is greater than 0 then count variable B ignoring the duplicates with the use of distinct.
IF (A > 0, count (DISTINCT B))
If Variable A is greater than 0 then count variable B ignoring the duplicates with the use of distinct.
In sql:
count(distinct case when a>0 then b else null end)
In excel(using array with ctrl+shift+enter) assuming your data is found on columns A & B:
=SUM(IF(A:A>0,IF(FREQUENCY(B:B,B:B)>0,1),""))
In Qlikview:
Normal expression:
=SUM(IF(A > 0,(DISTINCT B),0))
Unaffected by selections:
=Sum({1} IF(A > 0,(DISTINCT B),0))
SQL:
SELECT COUNT(DISTINCT CASE WHEN A > 0 THEN B ELSE NULL END) AS CountField
FROM yourtable
You could use the following:
=Count(DISTINCT IF (A > 0, B))
I would use
=Count(DISTINCT {<A = {>0}>} B)
However the latter will ignore any selections on A