# 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="/files/yub8jlry5ciPMkFcIs99" 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="/files/iXhXz3gVEcQ6zY4irw0f" 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="/files/vhsa9LHFuzGBpRtPMZbE" alt=""><figcaption><p><strong>After applying IFNAN</strong></p></figcaption></figure>


---

# 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://docs.valq.com/model/formula-functions/logical-functions/ifnan.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.
