# Else-If

This is a pre-built Action located under the **@Generic Element**. The functionality of this action in Avo Assure is to evaluate whether the specified condition is satisfied. If the initial If condition fails, the **Else-If** part is executed as an alternative conditional part. The result is stored in the given dynamic variable for further use during test execution..

{% hint style="info" %}
**Note**: Without **If** action we cannot execute **Else-If** action.
{% endhint %}

## Syntax

**Input Value**:`(<operand1>;<operator>;<operand2>)`&#x20;

| Argument                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                    |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p>\<operand1><br>(Required)</p> | <p>Provide the first value which you want to compare against operand2. <br>This can be a static value or a dynamic variable. <br>Supported input formats:  </p><p><strong>Number</strong> and <strong>String</strong> </p>                                                                                                                                                                                                     |
| <p>\<operator><br>(Required)</p> | <p>This is the comparison operator.  </p><p>Supported operators include: </p><p><strong>></strong>, <strong><</strong>, <strong>==</strong>, <strong>>=</strong>, <strong><=</strong>,<strong>!=</strong>, <strong>in</strong>, <strong>not in</strong> along with the logical operators <strong>AND</strong>, <strong>OR</strong>, <strong>NOT</strong>. </p><p><strong>Note</strong>: The operators are case-sensitive. </p> |
| <p>\<operand2><br>(Required)</p> | <p>Provide the second value which you want to compare against operand1. <br>This can be a static value or a dynamic variable.  </p><p>Supported input formats:<br><strong>Number</strong> and <strong>String</strong></p>                                                                                                                                                                                                      |

**Output Value**: \<Dynamic Variable>(Optional);\<Dynamic Variable>(Optional)

<table><thead><tr><th width="331.33343505859375">Argument</th><th>Description</th></tr></thead><tbody><tr><td>&#x3C;Dynamic Variable>(Optional);&#x3C;Dynamic Variable>(Optional)</td><td>Both dynamic variable stores the status as <strong>True</strong> or <strong>False</strong>.</td></tr></tbody></table>

### **Example 1: Evaluating an Additional Condition When the Initial If Condition Fails**

In this example, we explain how to evaluate another condition when the first If condition does not meet the defined criteria.

* **Action**: Else-If
* **Input Value**: ({Income};==;60000)
  * The variable (**{Income}**) specifies the dynamic variable whose value is being evaluated. In this scenario, the value stored in the **{Income}** variable is 60000.
  * The operator (**==**) defines the comparison rule. This operator checks whether the value of the variable **{Income}** is equal to the specified number (60000).
  * The number (**60000**) specifies the threshold against which the **{Income}** value is compared.
* **Output Value**: {Status}
  * The result of the evaluate operation is stored in the **{Status}** dynamic variable with the following possible values:
    * **True**: If the Else-If part executes successfully.
    * **Fales**: If the Else-If part does not execute because the If condition is fulfilled.
* **Logical Explanation**: The **Else-If** action evaluates the condition defined in the **Input Value** column (**({Income};==;60000)**), but only after the initial If condition evaluates to false. In this scenario, the value stored in the **{Income}** variable is 60000, which satisfies the condition. If the condition is true, the actions inside the **Else-If** block are executed. In this scenario, the **Display Variable Value** action displays the value of the **{TaxRate2}** variable (20%). The result of the evaluation operation (True) is stored in the **{Status}** variable.

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2FzmgNEgEBj6yHiAWpgQbb%2Funknown.png?alt=media&#x26;token=def40a32-2f24-4764-9756-aebd94adb822" alt=""><figcaption></figcaption></figure>

### **Example 2: Verifying String Presence When the Initial If Condition Fails**

In this example, we explain how to evaluate whether the value stored in one variable exists within another string or variable, but only when the previous If condition evaluates to false.

* **Action**: Else-If
* **Input Value**: ({Department};in;Technology)
  * The variable (**{Department}**) specifies the variable containing the value to be evaluated. In this scenario, the value stored in the **{Department}** variable is Technology.
  * The operator (**in**) defines the comparison operator used to check whether the value from the dynamic variable exists within another provided string or variable.
  * The string (**Technology**) specifies the exact string in which the search will be performed.
* **Output Value**: {Status}
  * The result of the evaluate operation is stored in the **{Status}** dynamic variable with the following possible values:
    * **True**: If the Else-If part executes successfully.
    * **Fales**: If the Else-If part does not execute because the If condition is fulfilled.
* **Logical Explanation**: The **Else-If** action evaluates the condition provided in the **Input Value** column (**{Department};in;Technology**). When the initial If condition has already failed. It checks whether the value stored in the **{Department}** variable (Technology) exists within the comparison string **Technology**. In this scenario, the value matches, so the **Else-If** condition evaluates to true, and the steps inside the **Else-If** part are executed. If the condition were false, execution would move to the next Else If block or end the loop part.

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2FsOS7SliqiIf2ljq5u8Cr%2Funknown.png?alt=media&#x26;token=fdd84386-d360-473f-a417-91430a473cc1" alt=""><figcaption></figcaption></figure>
