---
title: "How should I refer to a code list value in an expression?"
url: "https://openforis.support/questions/29/how-should-i-refer-to-a-code-list-value-in-an-expression"
tags: ["collect"]
status: "accepted"
score: 0
answer_count: 3
asked: "2014-10-09T20:40:57"
last_activity: "2020-10-13T15:56:45"
source: "Open Foris Support - Q&A Forum"
license: "Copyright Open Foris, 2026. Some rights reserved under creative commons license."
---

# How should I refer to a code list value in an expression?

Asked by Andras on 2014-10-09

Hi,

When I refer to a code list value in e.g. a relevancy expression of an attribute, should I use the code or the code label?
For instance I want that an attribute is relevant when the code attribute "accessibility" takes the value 1 (code label: "Accessible"). Which of the following is correct?

Relevant when: accessibility=1

or

Relevant when: accessibility="Accessible"

Thanks!


## Accepted answer (score 1, by Stefano (OF) on 2014-10-09)

Link: https://openforis.support/questions/29/how-should-i-refer-to-a-code-list-value-in-an-expression/39

Hi, when referencing a code attribute, only the **code** will be considered (don't forget that you can define surveys in multiple languages and you can define different labels for the same code item...). 
The right expression will be: **accessibility='1'** 


----------


Don't forget that the code is a alphanumeric value, so you have to wrap it into single or double quotes when you want to use it as a value in an expression. Thanks.


## Answer (score 1, by Stefano (OF) on 2020-10-13)

Link: https://openforis.support/questions/29/how-should-i-refer-to-a-code-list-value-in-an-expression/2932

Dear user,  
If **accessibility** is a Boolean attribute you can use just:

 - **accessibility** (that is equivalent to **accessibility = true()** ) 
 - **not(accessibility)** (equivalent to **accessibility = false()** )

**accessibilty = '1'** or **accessibility = '0'** can be used only if **accessibility** is a Code attribute.  

Thanks,  
Open Foris Team


## Answer (score 0, by EarthOrbGIS on 2020-10-13)

Link: https://openforis.support/questions/29/how-should-i-refer-to-a-code-list-value-in-an-expression/2931

Hi I know this discussion thread is slightly dated, but I would like to add some points from my own experience for other users who are looking for information regarding using expressions in the 

**Survey Designer >>> Schema >>> Attribute >>> Relevant >>> Only when expression is verified** 


----------


If '**accessibility**' is a **Boolean attribute**, you can use
 


----------


 - **accessibility = '1'**

meaning that this survey attribute only appears when '**accessibility**' was assessed as '1' i.e. not accessible, or you can write the following expression


----------


 - **accessibility = '0'**

 
meaning that this next attribute only appears when '**accessibility**' was assessed as '0' i.e. accessible.


----------


If '**accessibility**' is instead a **Code attribute** with multiple code elements as listed in **Survey Designer >>> Code Lists**, you may use similar expressions as before to configure your survey such that the next attribute only appears when a certain code list element (numerical) is selected,
 


----------


 - **accessibility = '5'**

meaning that the next attribute only appears when '**accessibility**' was assessed as '5'.


----------


Also, to include multiple conditions for the expression, you can use simple conditional expressions


----------


 - **(accessibility = '2') or (accessibility = '3')**

meaning that this next attribute only appears when '**accessibility**' was assessed as either '2' or '3'


----------


If you have another code attribute (e.g. '**agriculture_type**'), then you can write the following expression


----------


 - **(accessibility = '2') and (agriculture_type = '3')**

meaning that this next attribute only appears when '**accessibility**' and '**agriculture_type**' was assessed as '2' and '3' respectively.


----------


A less common example, is if you want a question to pop up when any list element was selected in the previous question. In this case, you would write the following expression


----------


 - **agriculture_type**

meaning that if you select any code list element under '**agriculture_type**', this next survey question will appear.


----------


Finally, you can write the following expression to exclude certain scenarios


----------


 - **agriculture_type != '3'**

meaning that the next survey question will pop up as long as you select any other code element other than '3' for '**agricultural_type**'. To clarify != is the notation used for 'not equals to'


----------


Hope you will find this helpful.
