# IFNAN

The IFNAN function checks for error and returns the default value if the value in the node is an error.

### Syntax

IFNAN(value1, value2?: number) - > number

### Arguments

<table><thead><tr><th width="161">Arguments</th><th width="141">Data type</th><th>Description</th></tr></thead><tbody><tr><td>value1</td><td>Number,Node reference</td><td>The node that is to be checked for error values.</td></tr><tr><td>value2?: number</td><td>Number,Node reference</td><td>The value that should replace the errors. The value should be of numerical datatype only.</td></tr></tbody></table>

### Return Value

value2 in the place of Error.

### Example

Consider the nodes **Total Cost** and **No. of units** to have the periods values as shown below:

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2FbwNxGmAC4Fg6k8TGybDm%2Fimage.png?alt=media&#x26;token=00cc2442-297b-4688-b65e-c31a9a25aae0" alt=""><figcaption></figcaption></figure>

Now, Cost per unit is calculated by dividing the Total Cost by No. of units. If IFNAN is not applied, the result would be as follows due to 'divide by zero' error:

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2FW8iyduyTLIRqr1NH2GlF%2Fimage.png?alt=media&#x26;token=dd6bd2bc-7b1b-4d0b-aef6-30ffd590e0bc" alt=""><figcaption><p><strong>Before applying IFNAN</strong></p></figcaption></figure>

The error is to be replaced with 0. To achieve this, the following formula should be written in the \[Cost Per Unit] node:

<mark style="color:blue;">**`IFNAN`**</mark>**`(`**<mark style="color:purple;">**`[Total Cost]`**</mark>**`/`**<mark style="color:orange;">**`[No. of units]`**</mark>**`,0)`**

### **Result**

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2Fg1yuKaHmsGiFAePd7CuM%2Fimage.png?alt=media&#x26;token=14e6f39b-162d-40ce-bd4d-e2c721673f1f" alt=""><figcaption><p><strong>After applying IFNAN</strong></p></figcaption></figure>
