# Using Spreadsheet Formulas

## <mark style="color:blue;">Using Spreadsheet Formulas to Enhance Test Sequences</mark>

Since the creation of test sequences in FunTEST is in a spreadsheet editor you can take advantage of using regular spreadsheet formulas to enhance the test sequence capabilities

## <mark style="color:blue;">Use Cases</mark>

### <mark style="color:green;">Creating Pass/Fail Criteria for a test step</mark>

Most common use case is to use spreadsheet formulas to create pass and fail criteria

#### Is Result within Limit?

The example below uses the following formula to verify if the result is within specified limits

```excel-formula
=IF(AND(L69>=J69,L69<=K69),0,1)
```

<figure><img src="/files/scYusu68PXfaER0XC5zP" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
You can create any custom pass/fail criteria by using spreadsheet formulas.

Always structure your formulas so if step passes display 0 and otherwise display 1

The pass/fail criteria you can create are only limited by spreadsheet formula capabilities&#x20;
{% endhint %}

### <mark style="color:green;">Post-processing Return value for result</mark>

Often times the raw result from the measurement step is not in the desired format. We can use spreadsheet formulas to convert return value to our desired format in the result cell

The example below uses the following formula to take absolute value from the return value

```excel-formula
=ABS(VALUE(O86))
```

<figure><img src="/files/xaaTUlVg2NjYcibkKBS7" alt=""><figcaption></figcaption></figure>

### <mark style="color:green;">Create conditions for step execution</mark>

You can also use spreadsheet formulas to create conditions for step execution.&#x20;

For example, you can make step execution dependent on the result of the previous step by using a formula in the exec column.

Below you can see that by using formula

```excel-formula
=IF(O14="0",1,0)
```

we can make 3 test steps only executed when the DUT is not present (return value = 0). If the return value is 1 steps are skipped and the sequence keeps executing

<figure><img src="/files/n3MsRSvWx3RhTCbAmtEd" alt=""><figcaption><p>Test sequence when DUT is present</p></figcaption></figure>

<figure><img src="/files/Zws4uicFkBBj5rtncygp" alt=""><figcaption><p>Test sequence when DUT is not present</p></figcaption></figure>

### <mark style="color:green;">Creating condition for command parameter</mark>

The same way you can change the exec column values with spreadsheet formulas, you can do the same for command's parameters.

For example, based on all the results from a test sequence, I want to display a message to the operator with the result i.e. Pass or Fail.

Here is how you can implement it using the following formula in the #status parameter cell at the end of the test sequence:

```excel-formula
="'Power-Up':panel=1:color="&IF(SUM(G25:G30)=0,"green","red")
```

<figure><img src="/files/EPyPVsLj8q26QYUmX5Dq" alt=""><figcaption><p>Test Sequence Example</p></figcaption></figure>

If all the results pass the sum is 0 and the panel color is green otherwise it's red. The rest of the formula are default parameters for #status command


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://funtest-1.gitbook.io/funtest-documentation/creating-test-sequence/using-spreadsheet-formulas.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
