# Variable from Multiselect in Collection

**URL:** <https://community.weweb.io/t/variable-from-multiselect-in-collection/5363>\
**Category:** Ask us anything\
**Created:** [November 12, 2023, 9:21pm UTC](https://community.weweb.io/t/variable-from-multiselect-in-collection/5363 "2023-11-12T21:21:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenboer](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/kenboer/32/2491_2.png) [@kenboer](https://community.weweb.io/u/kenboer)\
**Post date:** [November 12, 2023, 9:21pm UTC](https://community.weweb.io/t/variable-from-multiselect-in-collection/5363/1 "2023-11-12T21:21:44Z")

</div>

Hi,

I have a page of results which is filtered by a sidebar filter. Because I’m working with an external API pulled into Xano, each user will use tag filters, but they are displayed in different groups. The groups are collections.

 ![Screenshot 2023-11-12 at 3.13.12 PM](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/2/22212e50149e495096cfa108fa1a226b5e0fceb7.png)

In the screenshot above, Style, Frequency, and Type are each items in a collection. In each item, there is a multiselect in which they can choose filters. Each selection in the multiselect corresponds to an integer.

I am passing the results of these filters into a variable, using [this method](https://community.weweb.io/t/are-form-variables-not-visible-while-the-form-is-in-a-collection-item/1138/6).

The result is this:

{  
“2”: {  
“domEvent”: {},  
“value”: [  
2,  
5  
]  
},  
“3”: {  
“domEvent”: {},  
“value”: [  
13,  
8  
]  
},  
“4”: {  
“domEvent”: {},  
“value”:   
}  
}

My goal is to get a list of the values combined: [2, 5, 13, 8]. I can do parsing in Xano, but is there any way to get closer to my goal in WeWeb before doing that Xano parsing? The number of objects will vary by user.

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [November 12, 2023, 10:07pm UTC](https://community.weweb.io/t/variable-from-multiselect-in-collection/5363/2 "2023-11-12T22:07:09Z")

</div>

What I would do, is rather save the items from each select in an **array** , you can do this with **Change Variable Value** → **Insert at an index** and use your item.context.index

then it’s as simple, as doing a **rollup nocode formula**

 ![Screenshot 2023-11-12 at 23.05.56](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/6/6af4141fe5195ff292771e19a4ffd1cb3c2485d3.png)

I mean, you’re storing the items as “numbered” object’s properties (which are objects), so you might as well use an array, which basically is the same thing, but with some perks, like rollup formula.

---

<div class="post-metadata">

**Author:** ![kenboer](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/kenboer/32/2491_2.png) [@kenboer](https://community.weweb.io/u/kenboer)\
**Post date:** [November 13, 2023, 3:17am UTC](https://community.weweb.io/t/variable-from-multiselect-in-collection/5363/3 "2023-11-13T03:17:17Z")

</div>

Thank you, @Broberto. This is still a few steps beyond my knowledge at this point.

I can get at context.item.index. I see the “Insert at an Index” when I am using a an “array” variable. But I think I’m missing some granular steps here. Where are the values being collected before being rolled up?

I tried just adding all selected items to the end of an array, but then the deselect in the multiselect doesn’t work.

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [November 13, 2023, 8:15am UTC](https://community.weweb.io/t/variable-from-multiselect-in-collection/5363/4 "2023-11-13T08:15:28Z")

</div>

This is my setup

I bind an array so I can have a bound “collection” of multiselects

 ![Screenshot 2023-11-13 at 09.11.36](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/0/0f2c587b1713270bac8148f3adb7aa81657e9038.jpeg)

I set an action to update One item ad index that is item.index (the outermost)

 ![Screenshot 2023-11-13 at 09.11.44](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/e/e1bb46c406221194e0ea5521af2224f5ea304693.jpeg)  
Then I set the value to the event value array  
 ![Screenshot 2023-11-13 at 09.11.57](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/7/7e8c8e55bb8565889ba3c997ede6f26365a769d4.jpeg)

Finally, I use a function to join these arrays,

 ![Screenshot 2023-11-13 at 09.12.08](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/dc7bbe9a5d088e1e8a5743d9253c9ce48b0158bd.jpeg)

The function is the following

```auto
let newArr = []

// replace variables[...] with your array variable where you store the items from selects
variables[/* arr */'155b806a-1da6-40ab-bf17-23050456fafc'].map((item)=> {newArr=[...newArr, ...item]})

return newArr

```

With update one item, you also get to edit em, not just add them.

---

<div class="post-metadata">

**Author:** ![kenboer](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/kenboer/32/2491_2.png) [@kenboer](https://community.weweb.io/u/kenboer)\
**Post date:** [November 13, 2023, 2:37pm UTC](https://community.weweb.io/t/variable-from-multiselect-in-collection/5363/5 "2023-11-13T14:37:58Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [November 13, 2023, 2:40pm UTC](https://community.weweb.io/t/variable-from-multiselect-in-collection/5363/6 "2023-11-13T14:40:01Z")

</div>

No worries. Let me know if it helps! 🙂

---

<div class="post-metadata">

**Author:** ![kenboer](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/kenboer/32/2491_2.png) [@kenboer](https://community.weweb.io/u/kenboer)\
**Post date:** [November 13, 2023, 9:43pm UTC](https://community.weweb.io/t/variable-from-multiselect-in-collection/5363/7 "2023-11-13T21:43:45Z")

</div>

Yes, it worked perfectly. Thanks!
