Skip to content

Data: Forecast Sheet (data.forecastSheet) (#322) - #325

Merged
h-a-n-a-s-h-i merged 3 commits into
storytold:mainfrom
vangel76:feat/forecast-sheet
Oct 11, 2026
Merged

h-a-n-a-s-h-i merged 3 commits into
storytold:mainfrom
vangel76:feat/forecast-sheet

Conversation

@vangel76

Copy link
Copy Markdown
Contributor

Fixes #322

Stacked on #317 (FORECAST.ETS family). This branch contains #317's commit; review only the second commit (Data: Forecast Sheet …). Once #317 is merged I'll rebase this onto main.

What

data.forecastSheet (Data › Forecast › Forecast Sheet) builds a forecast sheet the way Microsoft's "Create a forecast in Excel" page describes it:

  • It inserts a new sheet before the active one and activates it. One undo step removes it again.
  • The sheet holds a copy of the timeline and the values, sorted by time. A text first cell is the header ("Timeline"/"Values" otherwise). Next to them are three columns:
    • Forecast(<values>): =FORECAST.ETS(A18,$B$2:$B$17,$A$2:$A$17,<seasonality>,<fill>[,<aggregation>])
    • Lower/Upper Confidence Bound(<values>): =C18∓FORECAST.ETS.CONFINT(…,<confidence>,…)
    • On the last history row, the forecast and bounds are set equal to the value, so the chart lines join.
  • With statistics: true it adds a FORECAST.ETS.STAT table (Alpha, Beta, Gamma, MASE, SMAPE, MAE, RMSE).
  • An Excel table covers the data, and a line chart (or a column chart with the bounds as lines) shows values, forecast and bounds.
  • The future time stamps continue the timeline's step, using calendar months for monthly dates. To do this, gridcraft-functions now exports a small Timeline (step detection shared with FORECAST.ETS, including its 30%-missing rule).

Params:

  • timeline/values: default is the first two columns of range, the selection or the current region.
  • end: a number or date text. Alternatively periods: default is a third of the history, at least 1, at most 10,000.
  • confidenceInterval, confidence (0.95 or 95), seasonality ("auto" / 0 / 2–8,760), fillMissing (interpolate/zeros), aggregate (average…sum), statistics, chart (line/column).
  • Invalid input returns a clear error: no constant step, an end before the data, a single column, mismatched sizes, a protected workbook structure.

UI: a Data ribbon button "Forecast Sheet" (Forecast group) opens a form dialog with these options. Programmatic calls never open it. The new ribbon label is translated in all catalogs (ja, zh, ko, ru, pt).

Tests

  • cmd::forecast::tests::forecast_sheet_builds_table_formulas_and_chart: sheet placement, headers, formula texts, future timeline, exact seasonal continuation (C18 = 47), bounds ordered, table range, chart series, undo.
  • cmd::forecast::tests::forecast_sheet_parameters_and_errors: explicit ranges, end as text, no confidence interval, manual seasonality, zeros, sum, column chart, and the error cases.
  • ets::tests::timelines_continue_past_their_last_point (numeric step, month ends, uneven timelines, too many missing points).
  • tests::every_command_survives_empty_params passes with the new command.
  • Offscreen snapshots of the generated sheet and the dialog, checked by eye.

Commands run:

cargo test -p gridcraft-engine --lib
cargo test -p gridcraft-functions
cargo test -p gridcraft-ui-egui --lib i18n
cargo clippy -p gridcraft-functions -p gridcraft-engine --all-targets -- -D warnings
cargo clippy -p gridcraft-ui-egui --lib -- -D warnings
cargo fmt -p gridcraft-functions -p gridcraft-engine -p gridcraft-ui-egui -- --check
cargo xtask parity   # 259 / 290
cargo xtask layers
cargo check -p gridcraft-engine --target wasm32-unknown-unknown
cargo run -p gridcraft-ui-egui --example snapshot -- … --cmd 'data.forecastSheet={…}' / --dialog 'forecastSheet={}'

Not done

  • No Forecast Start option (forecasting from a point before the end of the history, "hindcasting").
  • No live preview chart in the dialog.
  • The dialog takes ranges as text (no range picker), like the other form dialogs.

Unverified (needs confirmation in Excel)

  • The default forecast length. Ours is a third of the history; I haven't checked what Excel's Forecast End defaults to.
  • The exact column header wording, sheet placement (we insert before the active sheet), the table style, and the chart's styling and position.
  • Whether Excel writes the aggregation argument when it is AVERAGE (we omit it), and the argument values Excel's generated formulas use.

🤖 Generated with Claude Code

New sheet before the active one with the sorted history, a FORECAST.ETS
forecast column, FORECAST.ETS.CONFINT lower/upper bounds, an optional
FORECAST.ETS.STAT table, an Excel table over the data and a line or column
chart. Parameters: timeline/values (default: the selection's first two
columns), end or periods, confidence interval, seasonality, missing-point
fill, duplicate aggregation, statistics, chart kind. Data ribbon button
opens a form dialog; programmatic calls never do. gridcraft-functions
exports Timeline to continue a timeline (numeric step or calendar months).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
echelon and others added 2 commits October 11, 2026 13:12
# Conflicts:
#	ROADMAP.md
#	crates/engine/src/cmd/mod.rs
#	crates/ui-egui/src/dialogs.rs
#	docs/gaps.md
#	docs/parity-checklist.md
#	docs/ui-parity.md
The default periods (a third of the history, up to ~33k) bypassed
MAX_PERIODS, and each forecast row's three ETS formulas refit over the whole
history, so 100k history rows x 10k periods froze the app. History is now at
most 10,000 rows, periods at most 10,000, and history x periods at most
500,000 (about 3 us per history point per fit: a few seconds of recalc at
the cap). The default is clamped to the cap; explicit periods or an end past
it are refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit 7a34692 into storytold:main Oct 11, 2026
h-a-n-a-s-h-i pushed a commit that referenced this pull request Oct 11, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
h-a-n-a-s-h-i pushed a commit that referenced this pull request Oct 11, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@echelon

echelon commented Oct 11, 2026

Copy link
Copy Markdown
Member

Merged — thank you for the contribution! (I merged main into your branch — it keeps main's FORECAST.ETS from #317 and adds pivot: None for #313's Chart field — and bounded the work: history ≤ 10,000 rows, periods ≤ 10,000 and history × periods ≤ 500,000, so a large forecast can't freeze the app. I also added Spanish/German/Czech strings.)

If you haven't already, come join us on the ArtCraft Discord: https://discord.gg/artcraft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parity: Data › Forecast › Forecast Sheet (data.forecastSheet)

3 participants