> For the complete documentation index, see [llms.txt](https://docs.valq.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.valq.com/model/formula-functions/logical-functions/ifnan.md).

# 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&amp;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&amp;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&amp;token=14e6f39b-162d-40ce-bd4d-e2c721673f1f" alt=""><figcaption><p><strong>After applying IFNAN</strong></p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.valq.com/model/formula-functions/logical-functions/ifnan.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
