Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Tyler_Waterfall
Employee
Employee

Possible in Set Analysis to count distinct dates based on two separate fields?

I am trying to count the unique [Date] values which either had [flag_A]=1 OR [flag_B]=1.  Is this possible?

[flag_A] and [flag_B] are independent fields on 'associated' tables, but which will never both equal 1 in the same 'record' of the tables.  (Think of it as linking table A which is activity "starts" and table B which is activity "finishes".)

Seems like an if statement works:

count(distinct if(flag_A=1 or flag_B=1,Date))

but I wondered if such is possible and sensible with set analysis.

1 Solution

Accepted Solutions
jonasheisterkam
Partner - Creator III
Partner - Creator III

if i understood it right you search the XOR(/) or OR(+)

count({<flag_A={1}>/<flag_B={1}>} distinct Date)

count({<flag_A={1}>+<flag_B={1}>} distinct Date)

View solution in original post

5 Replies
sunny_talwar

Not sure if this will work, but try this:

=Count(Distinct {<flag_A = {1}>+<flag_B = {1}>} Date)

Qrishna
Master
Master

I am afraid if i had understood your situation.

but i would try writing the below expressions Also.

if(flag_A=1 or flag_B=1, count(distinct{$}Date))     

or

if( (flag_A=1 and flag_B=0) or (flag_A=0 and flag_B=1) , count(distinct{$}Date))   

or

Count(Distinct {$<flag_A=,flag_B= >} Date)

let me know if any of the expressions works for your situation.

We can proceed resolving your issue from there onwards.

krishna

jonasheisterkam
Partner - Creator III
Partner - Creator III

if i understood it right you search the XOR(/) or OR(+)

count({<flag_A={1}>/<flag_B={1}>} distinct Date)

count({<flag_A={1}>+<flag_B={1}>} distinct Date)

Tyler_Waterfall
Employee
Employee
Author

All these years and I never caught that I could define separate sets with the < >.

Thank you for your quick posts!

Here's what I ended up with:

(sum(TaskExecution)+sum([Reload in Hub]))/count({<TaskExecution={1}>+<[Reload in Hub]={1}>} distinct Date)

which as far as I can tell is equivalent to:

(sum(TaskExecution)+sum([Reload in Hub]))/count(distinct if(TaskExecution=1 or [Reload in Hub]=1,Date))

sunny_talwar

which as far as I can tell is equivalent to:

(sum(TaskExecution)+sum([Reload in Hub]))/count(distinct if(TaskExecution=1 or [Reload in Hub]=1,Date))

You are right Tyler