> 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/subtract.md).

# SUBTRACT

The SUBTRACT function returns the difference of all values in the arguments.

### Syntax

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

### Arguments

<table><thead><tr><th width="159">Arguments</th><th width="148">Datatype</th><th>Description</th></tr></thead><tbody><tr><td>value1</td><td>Number/Node reference</td><td>The first node or number to be subtracted. This is a required argument.</td></tr><tr><td>...valueN?</td><td>Number/Node reference</td><td>The additional nodes or numbers to be subtracted. These are optional arguments.</td></tr></tbody></table>

### Example

Consider the below example where we have Revenue and expenses data. The objective is to calculate the profit.

<table><thead><tr><th width="237">Periods</th><th width="138">Jan</th><th width="129">Feb</th><th width="133">Mar</th><th width="115">Apr</th><th width="64">May</th><th width="64">Jun</th><th width="64">Jul</th><th width="64">Aug</th><th width="64">Sep</th><th width="64">Oct</th><th width="64">Nov</th><th width="64">Dec</th></tr></thead><tbody><tr><td>  <mark style="color:purple;">Revenue</mark></td><td>300</td><td>450</td><td>367</td><td>408</td><td>832</td><td>671</td><td>700</td><td>260</td><td>572</td><td>903</td><td>534</td><td>671</td></tr><tr><td>       Sales</td><td>180</td><td>200</td><td>238</td><td>174</td><td>286</td><td>319</td><td>265</td><td>136</td><td>220</td><td>260</td><td>300</td><td>315</td></tr><tr><td>       Other revenue</td><td>120</td><td>250</td><td>129</td><td>234</td><td>546</td><td>352</td><td>435</td><td>124</td><td>352</td><td>643</td><td>234</td><td>356</td></tr><tr><td>  <mark style="color:orange;">Expenses</mark></td><td>170</td><td>173</td><td>360</td><td>264</td><td>174</td><td>184</td><td>582</td><td>273</td><td>503</td><td>296</td><td>295</td><td>484</td></tr><tr><td>        Rent </td><td>50</td><td>50</td><td>50</td><td>50</td><td>50</td><td>50</td><td>50</td><td>50</td><td>50</td><td>50</td><td>50</td><td>50</td></tr><tr><td>        Other expenses</td><td>120</td><td>123</td><td>310</td><td>214</td><td>124</td><td>134</td><td>532</td><td>223</td><td>453</td><td>246</td><td>245</td><td>434</td></tr></tbody></table>

To achieve this, the following formula should be written in the \[Profit] node.

<mark style="color:blue;">**`SUBTRACT`**</mark>**`(`**<mark style="color:purple;">**`[Revenue]`**</mark>**`,`**<mark style="color:orange;">**`[Expenses]`**</mark>**`)`**

### **Result**

<table data-header-hidden><thead><tr><th width="156">Column1</th><th width="153">Column2</th><th width="84">Column3</th><th width="84">Column4</th><th width="84">Column5</th><th width="84">Column6</th><th width="84">Column7</th><th width="84">Column8</th><th width="84">Column9</th><th width="92">Column10</th><th width="92">Column11</th><th width="92">Column12</th><th width="92">Column13</th></tr></thead><tbody><tr><td>Profit</td><td>130</td><td>277</td><td>7</td><td>144</td><td>658</td><td>487</td><td>118</td><td>-13</td><td>69</td><td>607</td><td>239</td><td>187</td></tr></tbody></table>


---

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