Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

cancel
Showing results for 
Search instead for 
Did you mean: 
cbushey1
Creator III
Creator III

Selecting values based on multiple states

HI there,

I have a field, RiskFactor, that appears in 3 listboxes, 1 for each alternate state.

RiskFactor can not be selected in the default state.

What I want to do is select another field, Patient_Key, based on the selections made from the 3 alternate states (Risk 1, Risk 2, Risk 3).

Basically, this would give me only those Patient_Key's that have all of the RiskFactors that were selected and NOT just one of them (like a list box does).

1 Solution

Accepted Solutions
rwunderlich

In your button, use a Select In Field action.

1. Field: Patient_Key

2. Search Expression:  ='(' & concat({Risk1*Risk2*Risk3}Patient_Key, '|') & ')'

That assumes your Patient_Key values have no spaces, if they do you have to mess with adding quotes into the search expression.

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

http://www.easyqlik.com

View solution in original post

13 Replies
petter
Partner
Partner

In QlikView there is something called AND-mode which is meant for the purpose you are describing. A list box is default in an OR-mode but can be toggled into an AND-mode in it's properties dialog under certain conditions.

https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/And-mode%20in%20List%20B...

AND-Mode

cbushey1
Creator III
Creator III
Author

Peter thanks for mentioning that option.

How can I use that with the alternate states method I outlined?

petter
Partner
Partner

How is your data model - specifically when it comes to the tables:

PATIENT

PATIENT_RISKFACTORS   (if it exists)

and

RISKFACTORS

?

cbushey1
Creator III
Creator III
Author

Patient table houses the Patient_Key field I am after, and it is joined to a table called RiskFactors which has two fields, Patient_ID and RiskFactor. PatientID is also in the Patient table so that is how they are joined.

petter
Partner
Partner

With the AND-mode listbox you will not need the alternate states as you select all the risk factors from a single list box.

2018-08-02 20_14_50-Edit Script [C__Users_Petter_Downloads_Patient Risks AND mode.qvw].png

2018-08-02 20_15_22-List Box Properties [Factor].png

You multi-select by holding the CTRL-key down while clicking. You will see that the other possible selections will be in white and if these are not to be considered for the final selected patient you will have to turn them into NOT selections that have the ! and red background as an indicator. Read more about that in the links I gave you previously.

cbushey1
Creator III
Creator III
Author

Peter,

Thanks for this approach but this doesnt really solve the question. I need a way to select the population in the default/current state, based on selections made in other states.

The example I listed is a simplified version of what I am doing in the application and many things are relying on the different states. The thing that will make what I built truly useful is being able to make this selection.

rwunderlich

Something along the line of:

count({< Patient_Key=P({Risk1})> * <Patient_Key=P({Risk2})>} Patient_Key)

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

http://www.easyqlik.com

cbushey1
Creator III
Creator III
Author

Thanks Rob.

How would I get my expression into a button to select the population?

I already have my populations being displayed on the screen:

Num(Sum([Risk1]*[Risk2]*[Risk3]*$ Patient_Count),'#,##0')

Not sure how to translate that into a button as I dont know how to add an expression as part of the actions.

rwunderlich

In your button, use a Select In Field action.

1. Field: Patient_Key

2. Search Expression:  ='(' & concat({Risk1*Risk2*Risk3}Patient_Key, '|') & ')'

That assumes your Patient_Key values have no spaces, if they do you have to mess with adding quotes into the search expression.

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

http://www.easyqlik.com