# What-If Analysis

## Content

SpreadJS Designer supports for What‑If Analysis, including **Scenario Manager**, **Goal Seek** and **Data Table**.
These features are available from the **Data** tab in the ribbon.
![SpreadJS Designer displays the What-If Analysis menu on the Data tab with Scenario Manager, Goal Seek, and Data Table commands.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260720.940daa.png?width=800)

## Scenario Manager

Scenario Manager allows you to create, apply, restore, delete, merge, and summarize scenarios in SpreadJS Designer.
A scenario is a named set of input values for changing cells. Applying a scenario writes those values to the worksheet and recalculates dependent formulas.

### Open Scenario Manager

1. Go to **Data → What‑If Analysis → Scenario Manager**.
2. The **Scenarios** panel appears.

![SpreadJS Designer demonstrates opening Scenario Manager from the What-If Analysis menu, causing the Scenarios panel to appear.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/open-20260720.63f5c2.gif?width=800)

### Manage Scenarios in the Scenario Panel

The **Scenarios** panel lists the scenarios in the workbook.
From the panel, you can:

* Create a scenario.
* Activate a scenario to record cell value edits.
* Apply a scenario to the worksheet.
* Restore an applied scenario.
* Delete a scenario.
* View the worksheets and changing cells included in a scenario.

![SpreadJS Designer demonstrates creating, activating, applying, restoring, and managing named worksheet scenarios through the Scenarios panel.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/manage-20260720.060d89.gif?width=800)
When a scenario is active, cell value edits are recorded into that scenario. Deactivating the scenario stops further recording but does not restore worksheet values.

### Generate a Scenario Summary

Click **Summary** in the Scenario panel to open the **Scenario Summary** dialog.
![SpreadJS Designer Scenarios panel provides a Summary command for generating a worksheet report from selected scenarios and result cells.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260720.f2564b.png?width=250)
![SpreadJS Designer Scenario Summary dialog allows developers to select scenarios, choose a report type, and specify result cells.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260720.ed4410.png?width=250)
In the dialog, you can:

* Select the scenarios to include in the report.
* Select the report type.
* Specify one or more result cells.

After you confirm the dialog, Designer generates a new worksheet containing the scenario summary report.

### Sheet Summary

A Sheet Summary report lists the selected scenarios side by side.
The generated report includes:

* A **Current Values** column.
* One column for each selected scenario.
* A **Changing Cells** section.
* A **Result Cells** section when result cells are specified.

If defined names are available for changing cells or result cells, the report displays the defined names. Otherwise, it displays cell references.

>type=note
> **Note:**
> The generated summary worksheet is a static snapshot and does not update automatically when scenarios or source cells change.

![SpreadJS Designer generates a static Sheet Summary worksheet comparing current values, changing cells, result cells, and selected scenarios side by side.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/sheet-20260720.61412f.gif?width=800)

### PivotTable Summary

A PivotTable Summary report creates a PivotTable for comparing scenario result values.
Scenario names are displayed as row labels. Each selected result cell is displayed as a value field. When multiple result cells are selected, each result cell is displayed as a separate value column.

>type=note
> **Notes:**
>
> * A PivotTable Summary requires at least one result cell.
> * In Excel, a Scenario Summary PivotTable has limited persisted source data. After the workbook is saved, closed, and reopened, Excel may not support refreshing the data source or changing field settings for that PivotTable. When SpreadJS imports an Excel file that contains this type of PivotTable, the imported PivotTable Summary may not exactly match the display saved in Excel.

![SpreadJS Designer generates a PivotTable Summary with scenario names as row labels and selected result cells as separate value fields.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/pt-20260720.335cff.gif?width=800)

### Merge Scenarios

Click **Merge** in the Scenario panel to import scenarios from another file.
![SpreadJS Designer Scenarios panel provides a Merge command for importing scenario definitions from another supported workbook file.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260720.8c4d21.png?width=250)
Designer supports importing scenarios from:

* `.sjs`
* `.ssjson`
* Excel files

After you select a source file, the **Merge Scenarios** dialog allows you to choose which scenarios to import.
![SpreadJS Designer Merge Scenarios dialog allows developers to select scenarios imported from an SJS, SSJSON, or Excel file.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260720.f55e9a.png?width=250)
If an imported scenario name conflicts with an existing scenario name in the current workbook, Designer ignores the imported scenario.

### Scenario Summary and Active Scenarios

Scenario summary reports are generated as report-only worksheets. If a scenario is active when the report is generated, changes made only to build the summary report are not recorded into the active scenario.

### Lock and Hide Scenarios

The lock ![SpreadJS Designer lock icon configures whether a worksheet-level scenario entry becomes read-only when worksheet protection restricts scenario editing.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260803.072552.png?width=20) and visibility ![SpreadJS Designer visibility icon configures whether a worksheet-level scenario entry remains displayed in the Scenario Panel during protection.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260803.5fe5bd.png?width=20) icons configure protection-related behavior for a worksheet-level scenario entry.
When the worksheet is protected and `allowEditScenarios` is not true, a locked entry is read-only and a hidden entry is not displayed in the Scenario Panel.
When `allowEditScenarios` is true, the entry remains editable and visible regardless of its locked and hidden settings.
![SpreadJS Designer Scenarios panel displays protection controls for configuring the locked and hidden states of worksheet-level scenario entries.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260721.c9e1a9.png?width=250)

## Goal Seek

Goal Seek determines the input value required to achieve a specified formula result.

### Open the Goal Seek Dialog

1. Go to **Data → What‑If Analysis → Goal Seek**.
2. The Goal Seek dialog appears.

![SpreadJS Designer Goal Seek dialog accepts a formula cell, target value, changing cell, maximum iterations, and calculation tolerance.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260326.eb2f6e.png?width=300)

### Configure Goal Seek

In the dialog, specify:

* Set cell: The formula cell whose result you want to control.
* To value: The desired result.
* By changing cell: The input cell that will be adjusted.
* Maximum iterations: The maximum number of calculation attempts.
* Tolerance: The acceptable difference between the calculated result and the target value.

Click OK to start the process.

### Goal Seek Execution

When Goal Seek starts:

* The system iteratively updates the changing cell.
* A Goal Seek Status pane displays the progress.
* You can review intermediate results during calculation.

When the result falls within the specified tolerance:

* A result dialog is displayed.

You can then choose:

* OK – Apply the final value to the worksheet. The operation supports undo.
* Cancel – Revert all changes made during the process.

## Data Table

A Data Table evaluates a formula using multiple input values and returns the corresponding results.

### Open the Data Table Dialog

1. Select the target range in the worksheet.
2. Go to **Data → What‑If Analysis → Data Table**.
3. The Data Table dialog appears.

![SpreadJS Designer Data Table dialog accepts row and column input cell references for evaluating formulas across the selected worksheet range.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260326.49fe99.png?width=300)

### Configure the Data Table

In the dialog, specify:

* Row input cell
* Column input cell

At least one input cell must be provided.
Click OK to confirm.
After confirmation:

* An `SJS.TABLE` formula is inserted into the selected range.
* The results are calculated automatically.

![SpreadJS Designer demonstrates configuring Data Table input cells, inserting an SJS.TABLE formula, and calculating results in the selected range.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/dataTable-20260720.ceef74.gif?width=800)

### Data Table Execution

During calculation, the Status Bar displays the progress of the Data Table evaluation.
You can monitor the percentage completed until the calculation finishes.
![SpreadJS Designer Status Bar displays the completion percentage while the Data Table calculation evaluates worksheet input combinations.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260421.eaad9e.png?width=300)

### Partial Calculation Mode

For performance optimization, Designer supports Partial Calculation mode for Data Table.
When enabled:

* `SJS.TABLE` formulas are not recalculated automatically when dependent values change.
* Users must manually trigger recalculation by clicking the Calculate button.

This mode is recommended when working with large data tables.
![SpreadJS Designer demonstrates Partial Calculation mode preventing automatic SJS.TABLE updates until the user manually invokes the Calculate command.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/partialCalc-20260720.6b8482.gif?width=800)

## See Also

* [What-If Analysis](/spreadjs/docs/features/what-if-analysis)
* [Partial Mode](/spreadjs/docs/features/formulas/calculation-mode#partial-mode)