DecCF./ˈdɛk.ɛf/

Create scenarios in the Calculator

Calculator scenarios let you compare named alternatives, such as lower income or higher rent, using the same application. Choose the individual input fields that should differ. Each alternative keeps the current values for every other field.

Before you start

Open a Calculator App with editable inputs. When creating an app in the editor, select Play once to show its inputs and calculate the first results. + Add scenario is available when the application declares at least one input.

An app can disable its Scenarios page with calculator: {scenarios: false} in defineModel. It then calculates the base inputs, and suggestions are not added. Saved scenario data remains in the case for use if the page is enabled again. See Organize input pages.

Suggest scenarios in the model

Add an optional scenarios list to defineModel to give a new calculation editable alternatives from the start. Each entry has a unique name and a partial input object keyed exactly like preconditions. For a model whose interest input is preconditions: {annualRate}, the declaration can include:

Nested inputs keep their paths. For example, an input declared under domain.financing.annualRate is proposed as input: {domain: {financing: {annualRate: 0.06}}}. Rates use decimal values in code, so 0.06 means 6%. Money values include both amount and currency, such as {amount: 4000, currency: "SEK"}. Objects may select individual fields; arrays and curves replace the complete selected value.

The Calculator adds the proposals as ordinary scenario cards when the model is first opened. Edit their values or remove them just like manually created scenarios. Fields omitted from a proposal keep following the current base inputs. Saved scenarios take precedence, including an intentionally empty list. Updating results or editing model code does not restore deleted proposals or overwrite edited cards.

A model can propose up to five scenarios. Names must be nonempty and unique, ignoring letter case. Proposals are plain data; they contain no callbacks. They do not change the meaning of a single base calculation or force other callers to execute a batch.

Create a scenario

  1. Open Scenarios in the input area and select + Add scenario.
  2. Enter a unique name that describes the alternative, such as Lower growth.
  3. Open the pages and groups in the field picker until you reach the fields you want to change. Tick one or more fields.
  4. Use Back or the breadcrumbs to choose fields from another page. Your selections remain checked as you navigate. Select Add scenario.
  5. Edit the values shown in the new scenario card, then select Update results to calculate all scenarios.

Selected fields start with their current values in the application's input area. The scenario card shows the path to each field, so similarly named fields in different groups remain distinguishable. Edits in that card are independent of the base inputs.

For example, after changing the base growth rate to 4%, a new Lower growth scenario starts at 4%. Change the scenario to 1% and select Update results. It uses 1% growth and the current base values for every other field. Later changes to an unselected base field apply to that scenario on the next calculation.

Change a field in every row

For a list of people, properties or other editable cards, open the list in the field picker and select one of its fields. The picker shows All rows use the selected value. The scenario applies that value to every current row while keeping the other fields in each row unchanged.

For example, select Family → Members → Salary to use the same salary for each member in one scenario. The members keep their names and other details. Nested lists work the same way. An empty list remains empty; selecting one of its fields does not add rows.

Input types and run settings

Scenario fields use the same kinds of controls as the base inputs. Money fields show their currency beside the amount; percentage fields show %. Enter 5 for 5%. Curves show editable dates and values, and text-file fields have a file picker. Selected fields start from the current base values, including curve points and loaded file contents, and can then be changed independently.

Run settings remain shared. Every scenario uses the current Run input options, including currency and calculation mode. In Monte Carlo mode, the trial count, sampling method and seed apply to each scenario. Use the result tabs above the reports to inspect each alternative.

Manage scenarios

You can create up to five scenario cards. Use a card's trash icon to remove it. Editing a card does not update its reports until you select Update results.

Use Save case as new or Save case in the case toolbar to keep your inputs, run settings and scenarios together. Open case restores a saved calculation setup. Case storage is available when the application allows it and you are signed in. Switching input pages does not discard scenario edits.

To define alternatives as part of a model, see Scenarios in the reference.

Keep a case in Google Drive

When Google Drive is available, open the Drive menu beside the case buttons. First save or open a normal case so its app version is retained. Save to Google Drive creates a visible file containing your inputs, scenarios and run settings. Open from Google Drive restores one of this app's files. Save as in Google Drive creates another file. Google asks you to choose an account and grant access to the files used by the app.

After saving or opening a Drive file, Save case writes to that Drive file. Opening a normal case or saving a new normal case switches back to normal storage. Drive saves leave the original case's inputs unchanged. Keep that original case: the Drive file needs it to recover the same app version. The file does not transfer access to the app to another person. If someone edits the Drive file after you opened it, reopen it before saving your changes.

If a calculation fails, expand Technical details below the error and use Copy error details when reporting it. Unexpected JavaScript failures also show a dialog with the available file, line, column and stack trace.