Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Announcing the newest addition to the Qlik Community, Qlik Gallery! Learn More
chhavi376
Contributor II

Need help in building an expression

Hi All,

I am facing an issue in building an expression in Qlik. PFB the details for the same.

The Raw data
patidTypecardiacchemodiabetesneuropreg
1 10111
2 10001
3 01101
4 11001
5 01101

These Types need to be added in the include and exclude filter

TypeInclude/Exclude
cardiacExclude
chemoInclude
diabetesInclude
neuroExclude
pregExclude

If selections are made in exclude filter, '0' values are selected corresponding to that flag

If selections are made in include filter, '1' values are selected corresponding to that flag

Case 1: When the user selects chemo from the Include filter

   

TypeIncExcpatient change when flag removed
cardiacExNot Applicable
chemoIn2
diabetesInNot Applicable
neuroExNot Applicable
pregExNot Applicable

   

patidTypecardiacchemodiabetesneuropreg
1 10111
2 10001
3 01101
4 11001
5 01101

For all other Type except the one selected from filter, the column will show "Not Applicable"'. Here in this case, the column will show "2" for selected type chemo because if this filter is cleared, 2 patid (1 & 2) will get added.

Case 2: When the user selects chemo from Include filter and cardiac from exclude filter

   

TypeIncExcpatient change when flag removed
cardiacEx1
chemoIn0
diabetesInNot Applicable
neuroExNot Applicable
pregExNot Applicable

   

patidTypecardiacchemodiabetesneuropreg
1 10111
2 10001
3 01101
4 11001
5 01101

For all other Type except the selected ones from include & exclude filter, the column will show "Not Applicable"'. Here in this case, the column will show "0" for selected type chemo because if this filter is cleared, no new patient will get added as we already have both the patid(3,5) selected. For selected type cardiac, if this filter is cleared, 1 patid (which is 4) will get added, hence value "1" for cardiac in the table

'patient change when flag removed'  needs to be created in the application attached

Thanks in advance

Regards,

Chhavi

3 Replies
sasikanth
Valued Contributor III

Re: Need help in building an expression

HI,

I did not understand the second scenario , try below exp

=if(Type=GetFieldSelections(Include),Count({<Flag={'0'}>}Flag),

if(Type=GetFieldSelections(Exclude),Count({<Flag={'1'}>}Flag),

'Not Applicable')

Partner
Partner

Re: Need help in building an expression

I am kind of in a hurry right now, but this looks like one of those very rare situations where you would need to use the "previous selection" state via a set analysis expression: {$1}

Check the "Identifiers" section here: https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/ChartFunctions/SetAnalys...

I'll give it a go later; in the meantime, I hope this helps you.

chhavi376
Contributor II

Re: Need help in building an expression

Hey,

This will be valid only for that flag which you just selected.

For the already selected flags it will give wrong results.

Regards,

Chhavi