# Selection Variable Issue

**URL:** <https://mworks.discourse.group/t/selection-variable-issue/939>\
**Category:** Support\
**Created:** [December 20, 2023, 8:18pm UTC](https://mworks.discourse.group/t/selection-variable-issue/939 "2023-12-20T20:18:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tt2405](https://avatars.discourse-cdn.com/v4/letter/t/13edae/32.png) [@tt2405](https://mworks.discourse.group/u/tt2405)\
**Post date:** [December 20, 2023, 8:18pm UTC](https://mworks.discourse.group/t/selection-variable-issue/939/1 "2023-12-20T20:18:42Z")

</div>

Hello Chris,

I have an mwel script where I need to generate a variable [signal\_pool\_indicies] from a range of integers. I am doing so by using the selection variable.  
However, I want my range of integers to be adjustable throughout the duration of the task, so I assigned a [low\_pool] variable and a [high\_pool] variable.

I used the low and high variables in the values parameter of my selection variable [signal\_pool\_indicies] hoping that I could change the range of integers that was being drawn in real time as the program was running. However I noticed that that was not the case and integers outside of the [low\_pool] and [high\_pool] range were being drawn. Eg. [low\_pool = 7] and [high\_pool = 14], however numbers less than 7 are still being drawn.

I have included a screenshot of the portion of code I am referring to.  
Does the values parameter not allow for variables in the range expression?

Best,  
Tiffany  
 ![Screen Shot 2023-12-20 at 3.11.20 PM](https://canada1.discourse-cdn.com/flex031/uploads/mworks/original/1X/aab7efc31cbdcbbb13891e040b2205ab5f293945.png)

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [December 21, 2023, 2:44pm UTC](https://mworks.discourse.group/t/selection-variable-issue/939/2 "2023-12-21T14:44:26Z")

</div>

Hi Tiffany,

A selection variable’s set of values is fixed when the experiment loads, so changes made to `low_pool` and `high_pool` while the experiment is running won’t change the values used by `signal_pool_indicies`.

If you know all the ranges you want to use ahead of time, you could create a separate selection variable for each range. Alternatively, if you fix the maximum range at experiment load time, you can manually reject values that lie outside the dynamic range when invoking [next\_selection](https://mworks.github.io/documentation/latest/components/next_selection.html), e.g.

```auto
next_selection (signal_pool_indicies)
while (signal_pool_indicies < low_pool or signal_pool_indicies > high_pool) {
    next_selection (signal_pool_indicies)
}

```

If you want to get fancy, you could drop the selection variable and use [Python actions](https://mworks.github.io/documentation/latest/components/run_python_file.html) to generate and draw from the list of values.

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [January 2, 2024, 2:49pm UTC](https://mworks.discourse.group/t/selection-variable-issue/939/3 "2024-01-02T14:49:11Z")

</div>


