Filter list based on other

Hello @sergiy I would like to filter some option in a list of reusable categories based on a cover question., e.g, I have a cover questio “country”, it has three answer options; “Colombia”, “Chile” and “Argentina”. Additionally, I have a lists of reusable categories with products part of the products are specific from a country as so on. How can I filter the categories based on the country selected in the cover.

Thanks, Jaime

Bonjour vous voulez filtrer les produits en fonction de la liste des pays, les produit sont spécifique a chaque pays c’est bien ca votre préoccupation ?
Voici comment il faut procéder tout d’abord :
on va nommé la variable ou se trouve la liste des pays : Liste_pays, et la variable ou se trouve les produit “Produit_pays”

   avec dans List_pays :
             1 pour Colombie
             2 pour Chili
             3 pout Argentine 

et dans Produit_pays :
1 pour Produit Colombie 1
2 pour Produit Colombie 2
3 pour Produit Colombie 3
4 pour Produit Chili 1
5 pour Produit Chili 2
6 pour Produit Chili 3
7 pour Produit Argentine 1
8 pour Produit Argentine 2
9 pour Produit Argentine 3

Les variables “Liste_pays” et “Produit_pays” sont de type “catégorielle : réponse unique”. Voici la syntaxe qu’il faut écrire dans filtre ;
syntaxe :
Liste_pays==1 ? @optioncode.InList(1,2,3):
Liste_pays==2 ? @optioncode.InList(4,5,6):
@optioncode.InList(7,8,9)

Thanks, this was very useful

Hello Jaime,

in general this is a case for a cascading question, where you can prescribe a value of the parent selector for each item.

Suggestion with InList() above is rather tedious, you need to remember to modify the lists of the items in your syntax, which is a lot of headache when the number of items is large or changes frequently. Instead it is better to group them into segments, e.g. 1000-1999 for Colombia, 2000-2999 for Chile, 3000-3999 for Argentina, etc. You don’t have to fill out all the segments completely, but determining the parent then is much easier with InRange() function, or with integer division, such as:

Math.Floor(@optioncode/1000.0)

People working in this field for many years will definitely ask you how are items treated if they can originate from multiple countries, such as coffee can be grown in Colombia and in Brazil. The above approach would necessitate you to introduce two codes for coffee (call them Colombian coffee, and Brazilian coffee). To avoid this, use the InList() as recommended, which will allow to mention the same item code multiple times.

In general however this can be solved with one or more lookup tables, in which you should store the possible country-item combinations.

The best solution would always require more details, such how many countries? how many items? do they overlap? do they vary? how often? how will the combinations be updated? do you know this at design time? etc.

Your situation is very similar to a price survey in which there are typically lists of items to be surveyed in particular stores. Perhaps colleagues from the stats offices of Laos and Cambodia can add their experience to this.

Best, Sergiy