Array values as a choice for user

Hello,

Im creating an app in releation to new cars.

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

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

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.
1 Like

3 posts were split to a new topic: Dynamic row count in Helper Table for Miracle method

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

(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

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.

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

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

Yeah its a choice component. Any thoughts?

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”.

2 Likes