> For the complete documentation index, see [llms.txt](https://docs.dataexport.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dataexport.io/kb/reports/custom-fields/calculated-fields.md).

# Calculated Columns

The '**Calculated Columns**' editor can be used to create a custom function for a particular field.&#x20;

### :clipboard: *Steps to Create a Calculated Columns*

1. **Click** on ![](/files/jDNspQY7ydL1AG0FfdqG) columns
2. **Click** on the '**Add** **Custom Column**' icon.

<figure><img src="/files/2oubX0QLR2rsDrOedSw3" alt=""><figcaption></figcaption></figure>

3. &#x20;**Click** on '**Calculated Columns**'
4. **Enter** the field name in the respective space provided.
5. **Click** on the blank space below to write a **custom function**. The function needs to be written in **PostgreSQL.**

{% hint style="info" %}
**Note:** Click on **Show Documentation** to view various functions that you can use. It is recommended to use this feature with basic knowledge of **PostgreSQL.**
{% endhint %}

{% hint style="info" %}
**Hint:** Type a keyword for the field to receive suggestions to add t the editor.
{% endhint %}

{% tabs %}
{% tab title="String" %}
These are the commands available under the **'String'** format along with its Syntax.

* Character Length&#x20;

  ```
  char_length([field_name])
  ```
* All characters in Lower Case

  ```
  lower(string)
  ```
* All letters in Upper Case

  ```
  upper(string)
  ```
* String Concatenation 2

  ```
  'String: ' || integer
  ```

{% endtab %}

{% tab title="Numbers" %}
These are the commands available under the **'Number'** format along with its Syntax.

* Adding two or more field values

  ```
  [field_name1] + [field_name2]
  ```
* Subtracting two or more field values

  ```
  [field_name1] - [field_name2]
  ```
* Multiplying two or more field values

  ```
  [field_name1] * [field_name2]
  ```
* Dividing two field values

  ```
  [field_name1] / [field_name2]
  ```
* **Limit** or **Truncate** the decimal values to 'n' number of decimal places.

  ```
  trunc([field_name],n)
  ```

{% endtab %}

{% tab title="Boolean" %}

* Greaater Than **( > ) :** Returns 'true' if first condition is greter than second condition, else return 'false'&#x20;

  ```
  [field_name1] > [field_name2]
  ```
* Lesser Than **( < ) :**  Returns 'true' if the first condition is greter than the second condition, else return 'false'

  ```
  [field_name1] < [field_name2]
  ```
* Greater than or Equal to **( >= ) :** Returns 'true' if the first condition is greater than or equal to the second condition, else return 'false'

  ```
  [field_name1] >= [field_name2]
  ```
* Lesser than or Equal to **( <= ) :** Returns 'true' if the first condition is less than or equal to the second condition, else return 'false'

  ```
  [field_name1] <= [field_name2]
  ```
* Equal to **( = )** : Returns 'true' if the first condition is equal to the second condition, else return 'false'

  ```
  [field_name1] = [field_name2]
  ```
* Not Equal to **( != ) :** Returns 'true' if both conditions are not equal else, return 'false'

  ```
  [field_name1] !=[field_name2]
  ```

{% endtab %}

{% tab title="Date & Time" %}

* Display Current date

  ```
  current_date
  ```
* Extracts only Day from Order Date

  ```
  extract (day from [Order Date])
  ```
* Extracts only Month from Order Date

  ```
  extract (month from [Order Date])
  ```
* Extracts only Year from Order Date

  ```
  extract (year from [Order Date])
  ```

{% endtab %}

{% tab title="Other custom fields " %}
Trunc: Trunc removes the fractional part of the number and rounds numbers down to the nearest integer based on the value of the fractional part of the number.

```
trunc(([fieldnme])::numeric, 2)
```

Round: The round() function rounds a number to a specified number of decimal places.

```
round(([fieldnme])::numeric, 2)
```

Float: Float is used to store approximate values, not exact values. It has a precision from 1 to 53 digits.

```
float(([fieldnme])::numeric, 2)
```

Concat:  Concat() function adds two or more expressions together.

```
concat([field_1],' ',[field_2],' ',[field_3])
```

{% endtab %}
{% endtabs %}


---

# 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.dataexport.io/kb/reports/custom-fields/calculated-fields.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.
