Relevant syntax if >1 choice is picked from list

4428
8
04-07-2016 10:19 AM
DougWilson3
New Contributor

I have a choices list that I want to appear as a question if either one of two different choices are selected from a list....I know that I can use a relevant entry of selected(${name}, 'choice') to display it when one choice is selected, but what entry can I enter to have the question displayed if either of these two choices are selected?

8 Replies
Joseph_Kinyon
Occasional Contributor II

Doug,
I'm not clear enough from your question to see the logic you need.

Am I paraphrasing correctly here?:

  1. You want an element to appear as a question in the form conditionally.
  2. You understand how to make this work if one item from a pick list is chosen.
  3. If your user chooses from a list, then your question appears if one of the items on the list is chosen and that could be more than one options
    --e.g. if the list is
    1. llama,
    2. alpaca,
    3. vicuña,
    4. guanaco
  4. Your question "ear length?" would appear if the user selects either 1. llama and 3 vicuña.
  5. You are not describing a multiple selection list such as the question conditionally appears only if they choose both 1. llama and 3 vicuña. (but you would probably like to know if that is possible)
  6. You are not trying to use an external select list

I made an example of the case described above as an .xlsx form for you to bring into a project.

You can access it here Index of /survey123

Download the Excel workbook, create a "New Survey" in Survey123 Connect, give New Survey a title and use the "Browse.." button to import the workbook and create a Survey123 project.

In this form, the questions of "ear length" and "take a photo of ear" are conditional and only appear if you select the first or third option on the list.

Test if this is the functionality you describe.

Joe

0 Kudos
Joseph_Kinyon
Occasional Contributor II

Doug,

In that table notice I made a column called "relevant"

The conditional question will appear base upon the formula in that question's relevant field.
On the condition that one of two choices is true out of a set of four+ choices, then the question appears.
You do this by saying in the formula that if the answer to the prior question equals either "this" or "that"  than the relevance of showing this particular question to the user is true.

This requires the use of an OR operator as shown.

selected(${critter},'llama') or selected(${critter}, 'vicuña')

I believe you can also use the AND operator.

Joe

JaromHlebasko
Occasional Contributor III

Is it possible to create a Relevant expression based on a Choice Filter? For example, say I have a list of 5 inspector names for the user to choose from. As the user chooses the appropriate name, a choice filter populates a list of projects. Once the user chooses the appropriate project, a relevant expression becomes visible with a yes or no value to choose from indicating whether or not that project has been inspected. It does not matter which project is chosen. I tried using a wild card like an ' * ' in an expression ${PROJECT} = '*' but no luck. I have the first two parts implemented but do not know how to create the relevant expression. Any help would be appreciated!

0 Kudos
Joseph_Kinyon
Occasional Contributor II

Jarom.

A Relevant expression is a choice filter.


For your situation you have a form that presents elements that are filtered and "relevant" to the particular inspector.

You have 5 inspectors:

  1. Jarom
  2. Jim
  3. John
  4. Joe
  5. Jan

Jarom and Jim inspect plumbing, John does electrical inspection, Joe does termites and Jan checks wheelchair access.

On the choices tab, you would make an inspector list

    

list_namenamelabelcategory
inspectorsJarom HlebaskoJaromelectrical
inspectorsJim JarmuschJimelectrical
inspectorsJohn JacobjingleheimerschmittJohnplumbing
inspectorsJoe MammaJoepests
inspectorsJan JohnsonJancompliance

On the Survey tab, for every element (or group) relevant to their inspection activity you make a formula that conditionally displays if it is true which simplifies the inspector's form to answer only questions he would observe but distribute one form.

I suggest bundling the questions relevant to them as one group (type=group, use begin_group & end_group to cluster them).

Using the structure below, the group of questions related to those inspectors name.

I only did two groups as an example, but you would have pests and compliance question groups too.

    

typenamelabelrelevant
select_one inspectorsinspectorsInspector Name
text favoritecolorcolorFavorite color today
begin groupelectricalElectrical Inspectionselected(${inpectors},'Jarom Hlebasko') or selected(${inspectors},'Jim Jarmusch')
integer plugsplugcountNumber of Plugs
text hazardobshazardHazard Observation
image hazardpichazardphotoPhoto of Hazard
end group
begin groupplumbingPluming Inspectionselected(${inpectors},'John Jacobjingleheimerschmitt')
text pipepipetypePipe Material
decimal diameterpipewidthOD of Pipe in decimal inches
end group

I personally would simplify this by having a "select_one inspectiontype"  list for picking a type of inspection instead of name>

This allows me flexibility if one of the inspectors may be qualified to do a number of inspection types and this would also help keep the formulas for "relevant" simple if I have 20 or 30 inspectors.

You can add this list in the choices tab like this

   

list_namenamelabel
posnegyesYes
posnegnoNo

Then make a select_one inspectedyesno option

typenamelabelrelevant
select_one inspectedyesnoinspectstatusInspected?

You can then check off whether one element had been inspected.

Clear as mud?

Joe

Joseph_Kinyon
Occasional Contributor II

If this or other things have been helpful, don't forget to click the "helpful yes no" and or like buttons, it helps sort for other users who have similar questions.

0 Kudos
JaromHlebasko
Occasional Contributor III

Thanks, I'm going to dive into your instructions right now and will mark it as helpful once I implement what your talking about (hopefully). Thank you for your time!

0 Kudos
Joseph_Kinyon
Occasional Contributor II

Jarom,

How did things work out?
Were you able to use relevant in you forms as you wished?

Hope things have been productive.

Cheers,

Joe

0 Kudos
JaromHlebasko
Occasional Contributor III

Thanks for reaching out Joe! Yes, you gave me some great insight on what I could do to solve the situation that I was in. I appreciate your help and support!

0 Kudos