> 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/math-functions/max.md).

# MAX

The MAX function returns the largest number in a set of values. Node references are also accepted as arguments.

### Syntax

MAX(value1, ...valueN?) - > number

### Arguments

<table><thead><tr><th width="134">Arguments</th><th width="144">Data type</th><th width="448">Description</th></tr></thead><tbody><tr><td>value1</td><td>Number, Node reference</td><td>The nodes or numbers for which you want to evaluate the largest value.</td></tr><tr><td>...valueN?</td><td>Number, Node Reference</td><td>Additional nodes or numbers for which you want to evaluate the largest value. This is an optional argument.</td></tr></tbody></table>

### Example&#x20;

Consider the below example with a node that has the demand for a particular product for 12 months.

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2FFNC9uc5WmFRD6aQyLAhu%2Fimage.png?alt=media&amp;token=7d5a5cb0-a18f-4f63-bdb6-b9ff90bdb2ff" alt=""><figcaption></figcaption></figure>

To calculate the maximum demand, the following formula should be written in the \[Maximum demand] node:

<mark style="color:blue;">**`MAX`**</mark>**`(`**<mark style="color:purple;">**`[Demand]`**</mark>**`.`**<mark style="color:blue;">**`ALL_PERIODS`**</mark>**`)`**

We are including [**.ALL\_PERIODS**](https://docs.valq.com/model/formula-functions/math-functions/pages/bd9R41FrVkmuCJPGQLmc#node-.all_periods) so that it will consider all the period values rather than one single period.

### Result

| **Maximum Demand** | 319 |
| ------------------ | --- |


---

# 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/math-functions/max.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.
