Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
baylor2016
Creator
Creator

Set analysis with alternate state

Hi

I am trying to generate a dynamic set analysis string based upon users' selections. The two list boxes in fact are the same data with different field names, and one is in NOT state. Is this ok to do it? I know data in Qlik are linked. A set analysis string for default state (it might not be necessary) and Not state are generated respectively and merged in one used in default state.

It looks like the generated set analysis string is correct, but the numbers returned is wrong. I am expecting the following expression returns 3, but it return 4 meaning the E() function is not working. Please advise. Thanks

=count(distinct {(<PatientID=p({<[Disease]={'Diabetes'}>} PatientID)>)*(<PatientID=E({<[Disease]={'CVD'}>} PatientID)>)} PatientID)

Sample project is attached.

Longmatch

1 Solution

Accepted Solutions
sunny_talwar

May be like this

=Count(distinct

{<PatientID = p({<Disease = p(Disease)>})

-

p({NOT<[Disease]={'Cancer', 'COPD'}>} PatientID)>}

PatientID)

and to make the second part dynamic, may be this

=Count(DISTINCT {<PatientID = p({<Disease = p(Disease)>})-p({NOT<[Disease]=p(Disease)>} PatientID)>} PatientID)

=Count(DISTINCT {<PatientID = p({<Disease = p(Disease)>})-p({NOT<[Disease]=p({NOT}Disease)>} PatientID)>} PatientID)

View solution in original post

18 Replies
sunny_talwar

May be this

=Count(DISTINCT {<PatientID=p({<[Disease]={'Diabetes'}>} PatientID)-p({NOT<[Disease]={'CVD'}>} PatientID)>} PatientID)

baylor2016
Creator
Creator
Author

Thank you for your help. It works fine.

If multiple conditions are selected in both list boxes (one in inherited state and the other in NOT state), I thought the following expression should work, but it doesn't. What I did wrong?

Thanks

=Count(distinct

{

<

PatientID=

p({

<[Disease]={'Diabetes'}>+

<[Disease]={'Depression'}>+

<[Disease]={'CHF'}>

} PatientID)

-

p({NOT

<[Disease]={'Cancer'}>+

NOT<[Disease]={'COPD'}>

} PatientID)

>

}

PatientID)

sunny_talwar

I believe this should work

=Count(distinct

{<PatientID=

p({<[Disease]={'Diabetes', 'Depression', 'CHF'}>} PatientID)

-

p({NOT<[Disease]={'Cancer', 'COPD'}>} PatientID)>}

PatientID)

baylor2016
Creator
Creator
Author

Logically this one is simpler. I will change the dynamic part to make it work. Thanks!!!

Do I need explicitly create set analysis string for Inherited state? I tried to use

=Count(distinct

{<PatientID=

$

-

p({NOT<[Disease]={'Cancer', 'COPD'}>} PatientID)>}

PatientID)


It returns zero.



Thanks.

sunny_talwar

With selection or without selections?

baylor2016
Creator
Creator
Author

With selection.

sunny_talwar

May be like this

=Count(distinct

{<PatientID = p({<Disease = p(Disease)>})

-

p({NOT<[Disease]={'Cancer', 'COPD'}>} PatientID)>}

PatientID)

and to make the second part dynamic, may be this

=Count(DISTINCT {<PatientID = p({<Disease = p(Disease)>})-p({NOT<[Disease]=p(Disease)>} PatientID)>} PatientID)

=Count(DISTINCT {<PatientID = p({<Disease = p(Disease)>})-p({NOT<[Disease]=p({NOT}Disease)>} PatientID)>} PatientID)

baylor2016
Creator
Creator
Author

I will try it and let you know the results. Thanks

sunny_talwar

Attaching an image and a sample

Capture.PNG