# Random display a subset of question library

**URL:** <https://forum.getodk.org/t/random-display-a-subset-of-question-library/18149>\
**Category:** Support\
**Created:** [February 27, 2019, 7:44am UTC](https://forum.getodk.org/t/random-display-a-subset-of-question-library/18149 "2019-02-27T07:44:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmtk41](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dmtk41](https://forum.getodk.org/u/dmtk41)\
**Post date:** [February 27, 2019, 7:44am UTC](https://forum.getodk.org/t/random-display-a-subset-of-question-library/18149/1 "2019-02-27T07:44:13Z")

</div>

Hi forum,  
My case is that I want to create a 20 questions examination. These 20 questions are randomly taken from a library of 100 questions.  
Is there a way to random display a subset of question library?

---

<div class="post-metadata">

**Author:** ![yanokwa](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/yanokwa/32/1695_2.png) [@yanokwa](https://forum.getodk.org/u/yanokwa)\
**Post date:** [March 3, 2019, 7:37pm UTC](https://forum.getodk.org/t/random-display-a-subset-of-question-library/18149/2 "2019-03-03T19:37:10Z")

</div>

If you search on the forum, you can find a few approaches to solving this problem. Try them!

- [Randomization of questions - #4 by yanokwa](https://forum.getodk.org/t/randomization-of-questions/13004/4)
- [Randomize order of questions - #10 by Mehrab\_Ali](https://forum.getodk.org/t/randomize-order-of-questions/3294/10)

---

<div class="post-metadata">

**Author:** ![Xiphware](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/xiphware/32/2587_2.png) [@Xiphware](https://forum.getodk.org/u/Xiphware)\
**Post date:** [March 3, 2019, 8:18pm UTC](https://forum.getodk.org/t/random-display-a-subset-of-question-library/18149/3 "2019-03-03T20:18:19Z")

</div>

> [@dmtk41](#):
>
> These 20 questions are randomly taken from a library of 100 questions.

Just to be sure, in addition to being randomly _selected_, do the questions also have to be randomly _presented/sorted_? (this additional constraint may affect possible solutions...).

---

<div class="post-metadata">

**Author:** ![dmtk41](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dmtk41](https://forum.getodk.org/u/dmtk41)\
**Post date:** [March 4, 2019, 2:29am UTC](https://forum.getodk.org/t/random-display-a-subset-of-question-library/18149/4 "2019-03-04T02:29:16Z")

</div>

Thank you @Yaw, @Xiphware  
The [Randomization of questions - #4 by yanokwa](https://forum.getodk.org/t/randomization-of-questions/13004/4) is close to the approach that I'm looking for. I did read this topic before but I stuck at preventing the random function generate duplicate number so potentially specific question maybe appear several times. Pls see my attached form.[sample.xlsx](https://getodk.b-cdn.net/uploads/default/original /2X/4/4158d67b468f2f1251ddf7641ae6c6b5ee9d7e91.xlsx) (14.8 KB)  
I found this thread about de-duplicate but look like it not work.

> [@Random number without duplicates/without replacement](https://forum.getodk.org/t/random-number-without-duplicates-without-replacement/6133):
>
> Dear all, I need to sample 20 households based on a household list. I was thinking I could sample them using ODK and the household rank number. Hence, I was looking for a way to generate 20 random numbers on ODK. I did the following 1+int(once(random())\*${total number of households in the village}) but this give me a random number with replacement and hence possibly with duplicates. I am looking to a way to do the same without replacement. Any idea? Thanks

The [Randomization of questions - #4 by yanokwa](https://forum.getodk.org/t/randomization-of-questions/13004/4) and **randomly _presented/sorted_** is also interesting me and I'm looking at them. I think I need it.
