# $abs

`$abs` operator helps you in calculating absolute value in an expression. You can use this in any [<mark style="color:blue;">**Expression Object**</mark>](/flow-builder/cql-cosmocloud-query-language/building-expressions.md).

for e.g.&#x20;

If you want to calculate change in temperature&#x20;

* change from 12 degree celcius to 18 degree celcius
* change from 18  degree celcius to 12 degree celcius&#x20;

Both of these should result in 6 degree change but using simple `$subtract` would give result as `6` and `-6` which is not a valid response.

## Syntax

```json
{
    "$abs":<value | expr>
}
```

### Properties

| Field            | Description                                                                                                                                                                                                                                                                                                     | Required |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| \<value \| expr> | <p>The <code>\<value></code> is any valid number.</p><p>The <code>\<expr></code> expression can be any valid <a href="/pages/E96SHGHwhXp256hQZFJ6"><mark style="color:blue;"><strong>expression</strong></mark></a> as long as it resolves to a number.</p><p></p><p>It can also be a Magical Autocomplete.</p> | true     |

### Returns

`number` - The result of $abs operation

## Examples

### Basic example

```json
{
    "$abs": -5
}
```

The above expression returns **6.0**

### With Nested Expressions

```json
{
    "$abs": { "$subtract": [1, 2] }
}
```

The above expression calculates the nested expression, return **-1** in its place and then the outer `$abs` expression returns **1** overall.

### With Magical Autocomplete

Let's say we have declared a variable `temp` in our API flow, which has a value of -8 currently.

```json
{
    "$abs":"$.variables.temp"
}
```

The above expression would resolve to a result of **8**


---

# 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.cosmocloud.io/flow-builder/cql-cosmocloud-query-language/building-expressions/usdabs.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.
