# Array values as a choice for user

**URL:** https://community.glideapps.com/t/array-values-as-a-choice-for-user/77399
**Category:** Ask for Help
**Created:** [October 28, 2024, 10:46am UTC](https://community.glideapps.com/t/array-values-as-a-choice-for-user/77399 "2024-10-28T10:46:45Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Lewis\_Parker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/lewis_parker/32/91147_2.png) [@Lewis\_Parker](https://community.glideapps.com/u/Lewis_Parker)
#### Post date: [October 28, 2024, 10:46am UTC](https://community.glideapps.com/t/array-values-as-a-choice-for-user/77399/1 "2024-10-28T10:46:45Z")

</div>

Hello,

Im creating an app in releation to new cars.

We have a list of car options from big query in this format:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/9/897778b7463351402399b9e9f357263a96aed364.png)

The end goal is to have the user be able to check some of the options in the array and have the prices add up into a seperate column so they can be factored into a master calculation

Any ideas as I feel like ive hit a wall here?

Our old python app we are migrating from looked like this

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/6/462b5af9908847dea034565003a963d65193c10c.png)

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [October 28, 2024, 11:03am UTC](https://community.glideapps.com/t/array-values-as-a-choice-for-user/77399/2 "2024-10-28T11:03:20Z")

</div>

The source of a choice component must be a single column, with one option per row.  
To transform what you have there you can use a technique commonly referred to as the “Miracle Method”. Essentially:

- Create a Helper Table with enough rows in it to cover the maximum number of expected options in the array
- Index the rows, starting at zero
- Add your array to every row of the table (could be multiple ways to do this)
- Use a Single Value column to take N from start of the array, where N is the Row Index. This will give you one array element per row.
- Use a series of Query JSON or JavaScript columns to extract the data elements from the JSON string.
- Stitch them back together using a template.
- Use the template as the source of your Choice component.

> [@fishbaguette\_breadbasket Transpose Columns to an Inline List: The Miracle Method](https://community.glideapps.com/t/transpose-columns-to-an-inline-list-the-miracle-method/32766):
>
> I’m often asked how to take columns of data (say form responses) and display them in an inline list. Here’s one way to do it—the MIRACLE METHOD. [[Glide: Transpose Data Columns into an Inline List with the MIRACLE METHOD] ](https://www.youtube.com/watch?v=t-sh_Q3WbQc)

> [@How do I create an auto-incrementing row number with Glide Tables?](https://community.glideapps.com/t/how-do-i-create-an-auto-incrementing-row-number-with-glide-tables/39572):
>
> This is a question that comes up a lot, so creating this topic to use as a reference. Typically, there are two distinct use cases when it comes to auto-incrementing row numbers. Use Case 1: – We need to generate a Part Number, or an Order Number, or an Employee ID. Once the number is generated, it should never change, even if rows are deleted. – The general approach for this use case is to maintain a static counter, use it to craft a suitably formatted ID, and increment it by one every time…

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [October 28, 2024, 11:59am UTC](https://community.glideapps.com/t/array-values-as-a-choice-for-user/77399/3 "2024-10-28T11:59:06Z")

</div>

3 posts were split to a new topic: [Dynamic row count in Helper Table for Miracle method](https://community.glideapps.com/t/dynamic-row-count-in-helper-table-for-miracle-method/77400)

---

<div class="post-metadata">

### Author: ![Lewis\_Parker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/lewis_parker/32/91147_2.png) [@Lewis\_Parker](https://community.glideapps.com/u/Lewis_Parker)
#### Post date: [October 28, 2024, 11:26am UTC](https://community.glideapps.com/t/array-values-as-a-choice-for-user/77399/4 "2024-10-28T11:26:15Z")

</div>

HI Darren, I have managed to do the miricle and get the options come back seperately.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/c/9c290a8b34ef0aba1d5091dcd499d37179812b14.png)

(i can sort the formatting later on)

how do i save the users choice? I need them to be able to click more than one and save the values (in the future the sum of the price selected) into the users table

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [October 28, 2024, 11:29am UTC](https://community.glideapps.com/t/array-values-as-a-choice-for-user/77399/6 "2024-10-28T11:29:44Z")

</div>

> [@Lewis\_Parker](#):
>
> how do i save the users choice?

That’s just a matter of configuring a target column for your choice component, which can be a column in the User Profile row. You can enable multiple select on the choice component. If your end goal is to calculate the sum of the selections, I would pull the price out separately and save that, and then perhaps use a JavaScript column to calculate the sum.

---

<div class="post-metadata">

### Author: ![Lewis\_Parker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/lewis_parker/32/91147_2.png) [@Lewis\_Parker](https://community.glideapps.com/u/Lewis_Parker)
#### Post date: [October 28, 2024, 11:33am UTC](https://community.glideapps.com/t/array-values-as-a-choice-for-user/77399/7 "2024-10-28T11:33:15Z")

</div>

I made a column for the selected choice in the user module (text column). Despite having allow selecting multiple when i click one of the checkboxes it does save the selection in the right column BUT it wil only save one. So if i click a 2nd option it replaces the first. And the checkboxes don’t actually check. they just look, on the frontend like they were never clicked

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [October 28, 2024, 11:35am UTC](https://community.glideapps.com/t/array-values-as-a-choice-for-user/77399/8 "2024-10-28T11:35:41Z")

</div>

Are you sure you’re using an actual choice component?  
Can you show me a screenshot of how that’s configured?

---

<div class="post-metadata">

### Author: ![Lewis\_Parker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/lewis_parker/32/91147_2.png) [@Lewis\_Parker](https://community.glideapps.com/u/Lewis_Parker)
#### Post date: [October 28, 2024, 11:51am UTC](https://community.glideapps.com/t/array-values-as-a-choice-for-user/77399/10 "2024-10-28T11:51:04Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/c/1c53644b0bab10ea643ddc193b00c3d5e72f6cde.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/a/5a12b41988d55e0e07b7f982b2dd0ebe23713b20.png)

Yeah its a choice component. Any thoughts?

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [October 28, 2024, 11:54am UTC](https://community.glideapps.com/t/array-values-as-a-choice-for-user/77399/11 "2024-10-28T11:54:00Z")

</div>

Okay, the problem is that your options contain commas. This breaks the multi-select because multiple selected options are written as a comma separated list.

Go back to my initial instructions - you should extract the individual items, then join them back together using a template (without any commas). I would use the template as “Display as”, and the price as “Values”.
