Mixing Live Data and Forecasts with the Time Slider

Advanced

Add a time slider to a dashboard to mark where history ends and the forecast begins, and use forecast_from() in formulas to switch between actual figures and simulated values.

Many dashboards tell two stories at once: what has happened (actual figures) and what will happen (the simulation). The time slider marks where one ends and the other begins. The history side usually comes from a live data source (see Bringing Live Data into a Twin).

Add it

  1. Under Controls in the Toolbox, drag Forecast from onto a simulation diagram.
  2. In the Properties panel, choose its Default position:
    • Today: on a twin with a calendar, the forecast starts at the current period.
    • Fixed step: a step you choose (counted from 0).
    • No cutoff: no forecast boundary until someone moves the handle.

The track spans the dashboard's time range, labelled with dates. It is blue up to the handle (history) and orange from it (forecast).

Moving it

Anyone viewing the dashboard can drag the handle, in the editor, the Reader or on a published site. The arrow keys, Home and End move it one step at a time. The simulation re-runs when you let go, and moving the handle never changes the model, so every viewer can try their own cutoff.

What charts show

Charts on the dashboard mark the cutoff too:

  • Line charts draw a vertical line at the cutoff and a light orange band over the forecast, labelled Actual and Forecast.
  • Bar charts draw forecast bars lighter, with an orange outline.
  • Tables shade the forecast rows.

The marks follow the handle as you move it, and exported images and PDFs include them.

Using it in formulas

The slider doesn't change your data by itself; your formulas decide what happens on each side. They read the boundary with forecast_from(): the step where the forecast starts, or nothing (()) when there is no cutoff.

let f = forecast_from();
if f == () || __timestep < f {
    agent.get_prop("actual_revenue")      // history: the real figures
} else {
    agent.get_prop("revenue", -1) * 1.02  // forecast: grow 2% per step
}

Written this way, the formula also works on dashboards without a slider.

Good to know

  • One slider per dashboard; a second one says it has no effect.
  • On a twin without a calendar, Today means no cutoff.
  • Exported images show the slider at its default position.

Next steps

  • Putting a Twin on a Calendar — dates, time ranges and Today
  • Adding Charts, Sliders, and Checkboxes — the other dashboard widgets
  • Writing Property Formulas — where forecast_from() is used
  • Bringing Live Data into a Twin — where the actual figures come from

This content was written collaboratively with AI.