Odk x CSV file multi-level filtered

We have a survey we are creating in odk x with numerous multi-level lists. We’re calling on CSV files, very much like the regions.csv file example in XLSX Converter documentation.
the lists go beyond two levels. For example, the city and the address to visit in this city so if I choice Brussel city I will receive only the street building of Brussel city that I put in the csv file ( column cvs file city and rue )

in the queries callback
city

_.chain(context).pluck(‘city’).uniq().map(function(city){
return {data_value: city, display: {title: {text: city} } };
}).value()

rue

_.map(context, function(place){
return { city: place.city, data_value: place.rue, display: {title: {text: place.rue} } };
})

but when I will choose the city the rue is not filtered. I receive all the list from my CSV file

Any help much appreciated.

Welcome to the ODK forum, @benamor! We’re glad you’re here. When you get a chance, please introduce yourself here. I’d also encourage you to add a real picture as your avatar because it helps build community!

Check out this example of a sub-form: quest2_02_1.xlsx (29.8 KB)
And this csv of geography: gov.csv (401.3 KB)

for how to get multiple levels (Governorate>Kism>Shyakha)

Think you Caroline for your help :slight_smile:
I did check the example that you give it to me that did help me a lot thinks and I wonder if I want to add 4de level I need to
put callback like the 3de one Shyakha or second one Kism?

hello caroline it’s me again :slight_smile: i did follow the example that you give it to me but he does not filter the data my xlsx file and csv file are here you can check please :slight_smile:

netwerk_inventaris.xlsx (19.2 KB)

villes.csv (3.7 KB)

think you

Hi @benamor!

So if you look at the example, you will see there is an additional column, choice_filter, that has information like:
choice_item.gov=== data(‘q2106_1’)
This is how you make sure it filters as you move down levels; you will need to do something equivalent for the ville in your case.

hi @elmps2018
think you it works perfectly :sunglasses: , I have other question if i want to add 4 filters which one should I use . it’s my last one over multiple levels filter :innocent:

(function() {
var seen = { };
return _.chain(context).filter(function(place) {
var keep = (seen[place.kism] !== true);
seen[place.kism] = true;
return keep; })
.map(function(place) {
place.name = place.kism;
place.label = place.kism;
place.data_value = place.name;
place.display = {title: {text: place.label} };
return place;
}).value

or

_.map(context, function(place){
place.name = place.shyakha;
place.label = place.shyakha;
place.data_value = place.name;
place.display = {title: {text: place.label} };
return place;
})

Hi @benamor!

So I think (but please report back) that you will need to do more like the first (kism) for levels 2 & 3, because basically you need to de-duplicate, and then more like the second (shyakha) for level 4, because you don’t need to de-duplicate there and the de-duplicating is what the extra syntax does. With the multi-level list, presumably everything but the last level needs to be de-duplicated. And will definitely need choice filter at 2, 3, and 4 levels.

hi @elmps2018
it doesn’t work but I did use 2 csv file and it works with the choice_filter think you, Caroline