# Creating a solver

Spark solver to perform a *What-If Analysis* similar to [Goal Seek](https://support.microsoft.com/en-us/office/use-goal-seek-to-find-the-result-you-want-by-adjusting-an-input-value-320cb99e-f4a4-417f-b1c3-4f369d6e66c7) at each API call. This is useful to determine the needed value to achieve a target input. For example, Goal Seek could be used to determine how long it would take to pay off a certain loan amount.

Users can build a simple solver that works similarly to Excel’s Goal seek function in order to perform a What-If Analysis. This solver is recognized by Spark and returns the forecasted value.

* For example, to reach a specific goal for the amount of annual premium paid by changing the sum assured. This is an effective method to find out how much an individual can be assured for, with a premium constraint.
* If a Spark Service has multiple solves, they will be executed in alphabetical order.

### How to create a solver block?

1. Navigate to the **Solver** application.
2. Click on **Create a solver**.
3. Select the **target cell** and the **changing cell.** Select the algorithm you wish to use, and the value you wish to target.

<figure><img src="https://272370975-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQQAtOKkd2V4rbmsT77rn%2Fuploads%2FembGVnfw6amvuPhps5VZ%2Fimage.png?alt=media&#x26;token=125a0d94-29dc-429d-83af-6f4ed93c5b47" alt="" width="368"><figcaption></figcaption></figure>

4. Select an empty area that is at least 2 cells wide, and 13 cells long.&#x20;

{% hint style="info" %}
You can rename the solver by changing the **XSolve\_\[address]** before creating or changing it through the name manager.
{% endhint %}

5. Once the indicator is green, click on the **Create** button to add the solver block to your selection.

### Solver Block Parameters

<table><thead><tr><th width="193">Key</th><th>Value</th></tr></thead><tbody><tr><td><code>Run if</code></td><td>A <code>TRUE</code> or <code>FALSE</code> value indicating whether or not this solve should be executed.</td></tr><tr><td><code>Target Cell</code></td><td>A link to the formulated cell that needs to reach the <code>Target value</code>. This is generally recommended to be defined as a difference between the desired <code>Target value</code> of <code>0</code>.</td></tr><tr><td><code>Target value</code></td><td>The value of the <code>Target cell</code> to achieve. This is best set to <code>0</code>.</td></tr><tr><td><code>By changing</code></td><td>A link to the cell that has to change in order to for the <code>Target cell</code> to reach the <code>Target value</code>.</td></tr><tr><td><code>Solve algorithm</code></td><td>The available options are <code>SECANT</code>, <code>STOPSATZERO</code>, <code>SMARTSECANT</code>, <code>BRENT</code>.</td></tr><tr><td><code>Max change</code></td><td>Maximum acceptable value of <code>|Solve result - Target value|</code> within <code>Max iterations</code>, default <code>1</code>.</td></tr><tr><td><code>Max Iterations</code></td><td>Maximum iterations for the number of solve.</td></tr><tr><td><code>Initial guess</code></td><td>Provide an initial guess to help reach the <code>Target value</code> sooner.</td></tr><tr><td><code>Solve Started</code></td><td><code>TRUE</code> or <code>FALSE</code> value. Spark will write this into the cell during execution. This enables downstream calculations to use this value.</td></tr><tr><td><code>Solve target</code></td><td>This is provided in order to help assess how close the solve was in reaching the target, given the solve can conclude within the <code>Max change</code>. Spark will write this into the cell during execution. This enables downstream calculations to use this value.</td></tr><tr><td><code>Solve iteration</code></td><td>Spark will write this into the cell during execution. This enables downstream calculations to use this value.</td></tr><tr><td><code>Solve result</code></td><td>This will contain either the successful solve value or <code>#N/A</code>. Spark will write this into the cell during execution. This enables downstream calculations to use this value.</td></tr><tr><td><code>Solve successful</code></td><td><code>TRUE</code> or <code>FALSE</code> value. Spark will write this into the cell during execution. This enables downstream calculations to use this value.</td></tr></tbody></table>
