I am trying to use choice_filter to filter the number of points on a map

1. What is the issue? Please be detailed.
I am collecting gps during enumeration that I plan to use in a follow-up survey. The gps from the enumeration is saved to an entity file. In the baseline, i want data collectors to be able to select points/households from a map based on the enumeration data. This was made possible through the entity functionality. But since the number of points can become very large, I want to be able to filter the options so data collectors don't get overwhelmed.
My thought is to filter the maps based on the household_id in the previous question.

Any idea how this could be implemented?

2. What steps can we take to reproduce this issue?
I have attached the sample form

3. What have you tried to fix the issue?
using choice_filter.

4. Upload any forms or screenshots you can share publicly below.

baseline_template.xlsx (20.9 KB)
sample_enum_form.xlsx (22.2 KB)

Good evening @Super_Kay and welcome to the ODK Community forum.
When you get a chance please take some time to introduce yourself here :slight_smile:

The choice_filter has to be applied on a column from the choices or entities list : https://docs.getodk.org/form-logic/#filtering-options-in-select-questions

In your case it should look like :

household_id = ${household_id}

1 Like

Many thanks for your response but this is still unclear to me.
I am generally familiar with applying choice filters when the options are in the choices tab. In my case, the geopoints are from an entity list that I am not sure how to access.

The entities tutorial uses choice_filter on entities :

Probably you'll need to complete the filter :

household_id = ${household_id} or name=current()/.

Everything you know about choice filters on lists from the choices tab applies to entity lists! The same way that you can use the name of a column from the choices tab (without quotes or ${}, just the name) to define what property of the choice to filter on, you can use an entity property name. That's the household_id side in the expression that @mathieubossaert wrote out.

Did you try the expression? What didn't work as expected?

One thing I don't understand from your description is that it seems to me like there would always be a single point/household location per household_id, is that correct? In that case, do you really need the data collector to select it or could you use a calculate to look it up? You could also do things like add a assigned_to property that represents a data collector id, have a question that asks for data collector id, and filter based on that. You could do the same concept by region.

In @Super_Kay's scenario as I understand it, that extra part of the expression should not be necessary. It's useful in the tutorial because the first part of the filter is based on a property that changes. The server always uses the latest entity list when you open up a submission. So let's say you open up a submission that addressed problem1, that same problem would have a status of addressed in the server entity list and therefore it would be filtered out by the expression. Adding name=current()/. means that the selected entity stays selected no matter what.

Welcome to the ODK community, @Super_Kay. Consider introducing yourself when you have a moment so we can learn more about the work you do!

1 Like

Thanks for the clear explanation @ln !

The map has no choices when I use household_id = ${household_id}

Thanks for the explanation @LN .
The map still has no choices when I use household_id = ${household_id} in the choice_filter column.

It shows 0 of 0 choices.

The other options you suggested are very interesting. Could you please share more details?

Thanks

Another option for me is to collect GPS at the start of the follow-uo form such that it is constrained by the original geopoint data collected in the enumeration. In other words, data collectors should be warned if the location from whoch they are trying to collect geopoint is more than 10 meters from the original location. The idea is to ensure that enumerators revisit and collect data from the right household.

Any help with this too will be truly appreciated.

Hi @Super_Kay, I found the problem.

You need to first calculate the household_id of the first selected entity.
Household_id is not the internal ID of the baseline entities;-), just one property.
Check this working xlsx :
baseline_template.xlsx (16,9 Ko)

3 Likes

Thanks @mathieubossaert !

It worked.

1 Like