How to get value from dataset in one column contains two values?

Hello All,

Im tryring to get values from datasets if in one column exsists two values then show users to select one value otherwise defaults should be show.
ex. please refer below data sets image.
Lets say if i select School A its has three Roles so user should have to select one role. if select school E its has only one Role then its not show to user to select its should defaut? Is it possible Please someone advise

PICK1

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

I suggest reformatting your data table and using a choice_filter.

Here's an example using your scenario: choice_filter_example.xlsx (11.0 KB)

2 Likes

Hi @danbjoseph

Thanks for your response

I'll try as per your suggestion. i have external data set file. is that possible to achieve same logic using from external data set file? because we have so many schools so we are using external data sets

See the documentation on Select from external dataset. You'll need a separate file for each list. Here is the reworked example:
choice_filter_example_external.xlsx (10.5 KB)
schools.csv (153 Bytes)
projects.csv (326 Bytes)
roles.csv (254 Bytes)

Hi @danbjoseph ,

Thanks for your response,

In Dataset Can we add Mulitple files?
Im not sure we can add one dataset in media files. Is that possible to add multiple files in media files? I can able to add one file in Media Files. if i try to add another file im getting error. you have shared schools.csv, projects.csv, roles.csv do we need to add those files in Media files?where should i add those files?

In Dataset i have another logic
In below image i have one school, one user filter
SchoolExample1

I need to show schools(schools should be unique its should not repeat) for different

Hi @danbjoseph ,

Sorry i Cant able to two embedded two files in one reply. please see previous reply and this continuation.

users. How can filter ex. school A should be visible to user1, user4

SchoolExample1

Regards,
Afrose

Central will only request the media files that are used in the survey form. It looks like you modified the questions from my example and only reference a single external file. The filenames used in the survey need to exactly match the filenames uploaded.

You would follow the same structure as with the other filters:
choice_filter_schools_example.xlsx (10.6 KB)
schools.csv (163 Bytes)

1 Like

Hi @danbjoseph
Thanks for your response, One more question

But School A is repeating twice, lets say if i have 1000 schools for user1 again I need to add same schools for user4. Instead is that possible to do below like this. Can seperate values by comma in user_filter and get values?

list_name name label user_filter
schools schoolA School A user1, user4
schools schoolB School B user2
schools schoolC School C user3

Regards,
Afrose

You can do that with a contains() function in the choice_filter. Here's a working example:

choice_filter_schools_example.xlsx (10.6 KB)

+-----------------------------------+--------+-------------------+----------+--------------------------------+
|               type                |  name  |       label       | required |         choice_filter          |
+-----------------------------------+--------+-------------------+----------+--------------------------------+
| select_one users                  | user   | Select a user:    |          |                                |
| select_one_from_file  schools.csv | school | Select a school:  | yes      | contains(user_filter, ${user}) |
+-----------------------------------+--------+-------------------+----------+--------------------------------+

schools.csv (137 Bytes)

+-----------+---------+----------+-------------+
| list_name |  name   |  label   | user_filter |
+-----------+---------+----------+-------------+
| schools   | schoolA | School A | user1 user4 |
| schools   | schoolB | School B | user2       |
| schools   | schoolC | School C | user3       |
+-----------+---------+----------+-------------+
1 Like