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

**URL:** <https://forum.getodk.org/t/how-to-get-value-from-dataset-in-one-column-contains-two-values/48501>\
**Category:** Support\
**Tags:** odk-xlsform\
**Created:** [July 31, 2024, 11:14am UTC](https://forum.getodk.org/t/how-to-get-value-from-dataset-in-one-column-contains-two-values/48501 "2024-07-31T11:14:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Afrose\_ahamed](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/afrose_ahamed/32/22969_2.png) [@Afrose\_ahamed](https://forum.getodk.org/u/Afrose_ahamed)\
**Post date:** [July 31, 2024, 11:14am UTC](https://forum.getodk.org/t/how-to-get-value-from-dataset-in-one-column-contains-two-values/48501/1 "2024-07-31T11:14:39Z")

</div>

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](https://getodk.b-cdn.net/uploads/default/original/3X/b/d/bdf3af8dac6632f7bf2f81e19e58f7a0107c881c.png)

---

<div class="post-metadata">

**Author:** ![danbjoseph](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/danbjoseph/32/21901_2.png) [@danbjoseph](https://forum.getodk.org/u/danbjoseph)\
**Post date:** [August 3, 2024, 4:57pm UTC](https://forum.getodk.org/t/how-to-get-value-from-dataset-in-one-column-contains-two-values/48501/2 "2024-08-03T16:57:46Z")

</div>

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](https://forum.getodk.org/t/-/6671). 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`](https://docs.getodk.org/form-logic/#cascading-selects).

Here's an example using your scenario: [choice\_filter\_example.xlsx](https://forum.getodk.org/uploads/short-url/ruNS6I2BYwYX262OVHhXjQxa0Hz.xlsx) (11.0 KB)

 ![Screenshot 2024-08-03 at 12.54.00 PM](https://getodk.b-cdn.net/uploads/default/original/3X/a/6/a68547562abf834110f372fdb409ead499aaeb6c.png) ![Screenshot 2024-08-03 at 12.54.11 PM](https://getodk.b-cdn.net/uploads/default/original/3X/c/8/c8b0ec8420fc4e9823209048eef525d782ae949d.png)

---

<div class="post-metadata">

**Author:** ![Afrose\_ahamed](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/afrose_ahamed/32/22969_2.png) [@Afrose\_ahamed](https://forum.getodk.org/u/Afrose_ahamed)\
**Post date:** [August 13, 2024, 5:02am UTC](https://forum.getodk.org/t/how-to-get-value-from-dataset-in-one-column-contains-two-values/48501/3 "2024-08-13T05:02:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![danbjoseph](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/danbjoseph/32/21901_2.png) [@danbjoseph](https://forum.getodk.org/u/danbjoseph)\
**Post date:** [August 13, 2024, 2:05pm UTC](https://forum.getodk.org/t/how-to-get-value-from-dataset-in-one-column-contains-two-values/48501/4 "2024-08-13T14:05:58Z")

</div>

See the documentation on [Select from external dataset](https://docs.getodk.org/form-question-types/#select-from-external-dataset). You'll need a separate file for each list. Here is the reworked example:  
[choice\_filter\_example\_external.xlsx](https://forum.getodk.org/uploads/short-url/4ogUAp9qhlBll3T3dmdgNuyMuFB.xlsx) (10.5 KB)  
[schools.csv](https://forum.getodk.org/uploads/short-url/u3Ygp47qyR0Z1Lc4L6qEwwAXfko.csv) (153 Bytes)  
[projects.csv](https://forum.getodk.org/uploads/short-url/z2mzquEmm26TKAOc91N9sHvdlX6.csv) (326 Bytes)  
[roles.csv](https://forum.getodk.org/uploads/short-url/49aI5po4EqALwJpDbDUFALO8s3g.csv) (254 Bytes)

---

<div class="post-metadata">

**Author:** ![Afrose\_ahamed](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/afrose_ahamed/32/22969_2.png) [@Afrose\_ahamed](https://forum.getodk.org/u/Afrose_ahamed)\
**Post date:** [August 14, 2024, 1:01pm UTC](https://forum.getodk.org/t/how-to-get-value-from-dataset-in-one-column-contains-two-values/48501/5 "2024-08-14T13:01:19Z")

</div>

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?

 ![DataFile1](https://getodk.b-cdn.net/uploads/default/original/3X/b/c/bc88239f7569309efd5b444abee47f34545f03c3.png)

---

<div class="post-metadata">

**Author:** ![Afrose\_ahamed](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/afrose_ahamed/32/22969_2.png) [@Afrose\_ahamed](https://forum.getodk.org/u/Afrose_ahamed)\
**Post date:** [August 14, 2024, 1:02pm UTC](https://forum.getodk.org/t/how-to-get-value-from-dataset-in-one-column-contains-two-values/48501/6 "2024-08-14T13:02:28Z")

</div>

In Dataset i have another logic  
In below image i have one school, one user filter  
 ![SchoolExample1](https://getodk.b-cdn.net/uploads/default/original/3X/0/d/0d77b4da9a40058fa4aa8bbab1c20445ceb25358.png)

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

---

<div class="post-metadata">

**Author:** ![Afrose\_ahamed](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/afrose_ahamed/32/22969_2.png) [@Afrose\_ahamed](https://forum.getodk.org/u/Afrose_ahamed)\
**Post date:** [August 14, 2024, 1:04pm UTC](https://forum.getodk.org/t/how-to-get-value-from-dataset-in-one-column-contains-two-values/48501/7 "2024-08-14T13:04:16Z")

</div>

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](https://getodk.b-cdn.net/uploads/default/original/3X/0/d/0d3c7a17594f468e82889c40477a425a59532fd9.png)

Regards,  
Afrose

---

<div class="post-metadata">

**Author:** ![danbjoseph](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/danbjoseph/32/21901_2.png) [@danbjoseph](https://forum.getodk.org/u/danbjoseph)\
**Post date:** [August 14, 2024, 1:59pm UTC](https://forum.getodk.org/t/how-to-get-value-from-dataset-in-one-column-contains-two-values/48501/8 "2024-08-14T13:59:27Z")

</div>

> [@Afrose\_ahamed](#):
>
> In Dataset Can we add Mulitple files?

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.

> [@Afrose\_ahamed](#):
>
> How can filter ex. school A should be visible to user1, user4

You would follow the same structure as with the other filters:  
[choice\_filter\_schools\_example.xlsx](https://forum.getodk.org/uploads/short-url/mexfoaOHAqcKf1cw9pFM9fbq5Wg.xlsx) (10.6 KB)  
[schools.csv](https://forum.getodk.org/uploads/short-url/82mO4qIqwi9hmLbaZVdKQdAePIE.csv) (163 Bytes)

 ![Screenshot 2024-08-14 at 9.57.27 AM](https://getodk.b-cdn.net/uploads/default/original/3X/a/b/ab694dc567cfb088b7fb92ee0f6aaad6fd1d5a1f.png) ![Screenshot 2024-08-14 at 9.57.30 AM](https://getodk.b-cdn.net/uploads/default/original/3X/f/d/fd75ae673b7ee9f0ccfd5015529703f9f4b0f774.png) ![Screenshot 2024-08-14 at 9.57.33 AM](https://getodk.b-cdn.net/uploads/default/original/3X/9/9/99e96a49d4971fad239e5e9cf9085bd4c53384b7.png)

---

<div class="post-metadata">

**Author:** ![Afrose\_ahamed](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/afrose_ahamed/32/22969_2.png) [@Afrose\_ahamed](https://forum.getodk.org/u/Afrose_ahamed)\
**Post date:** [August 14, 2024, 6:19pm UTC](https://forum.getodk.org/t/how-to-get-value-from-dataset-in-one-column-contains-two-values/48501/9 "2024-08-14T18:19:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![danbjoseph](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/danbjoseph/32/21901_2.png) [@danbjoseph](https://forum.getodk.org/u/danbjoseph)\
**Post date:** [August 14, 2024, 7:22pm UTC](https://forum.getodk.org/t/how-to-get-value-from-dataset-in-one-column-contains-two-values/48501/10 "2024-08-14T19:22:25Z")

</div>

You can do that with a [`contains()`](https://docs.getodk.org/form-operators-functions/#contains) function in the `choice_filter`. Here's a working example:

[choice\_filter\_schools\_example.xlsx](https://forum.getodk.org/uploads/short-url/tQQEgkNC8qLGt7MmQMfASNKLj6v.xlsx) (10.6 KB)

```plaintext
+-----------------------------------+--------+-------------------+----------+--------------------------------+
| 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](https://forum.getodk.org/uploads/short-url/ar2VRBqmN06Ebyr5nfTBj6QZfS4.csv) (137 Bytes)

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

```
