Create array from user inputs

Hi All,

Am trying to figure the right way how to populate an array of outcomes from 5 user inputs. The inputs are:

Inputs

  • Step 1: date_input_1 and integer_input_1

  • Step 2: date_input_2 and integer_input_2

  • Step 3: modifier_variable_X

Outputs

  • Step 1 creates two outputs per row. Approx 100 rows.

  • Step 2 creates two outputs per row. Approx 100 rows.

  • Step 3 sums the four outputs per row and applies a user input modifier to it.

The outputs in Step 1 and Step 2 are formulas derived from the user inputs (ie date and input create a different result per row).

I would like to view the five outputs (step 1, step 2, and the sum of the two) in a single table and chart. Would like this notebook to be embedded in a website.

Not sure if this is enough background, happy to clarify any of it.

I’ve seen loops and map as possible options, but not sure of the best approach here. Appreciate any insights on how to approach this.

I would use map over loop.

If you shared a basic notebook with cool.

See this notebook on making a from input.

The outputs could be in a table format as described here.

Get the basics going and if you have issues ask for help.

1 Like

Thanks, Brett. I’ll work through the forms and mapping approach. Not much to share on this one yet, but as it builds out I’m sure I’ll have some more questions!

(disregard date issues, looks like they were solved by converting to UTC)

I’m making some progress, but the Map syntax is throwing me a bit.

The objective here is to take user input number called PIA and modify it by multiplication against the array. The array contains a variable called ā€œCumulative Pen/Bonā€

PIA input is working.
socialSecurityCalculatorExportPiaAdj is the original array and working.
Map is returning undefined (I believe due to my syntax, but no errors showing).

Here’s the notebook: Untitled / mhgit10 / Observable

My mapping code:

PIA_map = new Map(
  socialSecurityCalculatorExportPiaAdj.map((o) => [
    o["Cumuluative Pen/Bon"],
    o["Cumuluative Pen/Bon" * "PIA"]
  ])
)

Input/Output
Input 5000 PIA
Desired output from map:
1: -0.300000000000 transforms to -1500
2: -0.295833333333 transforms to -1479.166666
etc

You almost have it. Change the line

o["Cumuluative Pen/Bon" * "PIA"]

to

o["Cumuluative Pen/Bon"] * PIA
2 Likes