---
title: LEFT
description: Learn how to use the LEFT function to extract a specified number of characters from the left side of a text string in calculated columns.
---
import { Steps } from '@astrojs/starlight/components';

# LEFT

The LEFT function returns a specified number of characters from the left side of a text string.

## Applicable to

Calculated Columns

## Return Value

* The LEFT function returns a text string containing the specified number of characters from the left side of the input text.
* If the number character is greater than the length of text, the entire text string is returned.

## Remark

* The LEFT function is useful for extracting a substring from the beginning of a text string. 
* If number character is less than 1, the function returns an empty string.
* If LEFT is a NULL value, the function returns NULL.

## Syntax

```
LEFT(<expression>,number)
```

## LEFT in Calculated Columns



| Expression             | A placeholder in a function that is replaced with the actual column name. |
|-------------------------|-----------------------------------------------------------------------|
| Column Name            | The name of the column in the dataset or Datasource that contains the values you want to analyze. |
| number                  | Number of characters you want to extract from the left side of the string. |

Steps to Use LEFT Function

<Steps>
1. Write the LEFT function. For instance ```LEFT(<expression>,number)```
2. Replace `<expression>` with `VALUE([Column Name])` and replace `number` with the number of characters you want to extract position of.
3. Replace the **Column Name** with the actual name of your column required.
4. To learn how to add calculated columns in Infoveave, visit the section [Calculated Columns](/studio-v8/datasources/calculated-columns-datasource/).
</Steps>

## Example

**Objective** Consider that you have the below sales dataset, your goal is extracting the first 2 substrings in CATEGORY from left.

| ORDER DATE | COUNTRY | CATEGORY   | UNIT PRICE | MARKET PRICE | QUANTITY |
|------------|---------|------------|------------|--------------|----------|
| 2024-01-03 | Brazil  | Baby Food  | 38.41      | 43.7874      | 2        |
| 2024-01-07 | Japan   | Spices     | 45.56      | 50.8155      | 20       |
|            | Japan   |            |            | 43.7874      | 10       |
| 2024-01-18 |         |            |            | 32.3019      | 4        |
| 2024-01-22 | Brazil  | Cosmetics  | 28.335     | 23.0109      | 7        |
| 2024-01-26 | Canada  |            | 20.185     | 23.0109      | 9        |
| 2024-01-04 | France  | Cereal     | 25.26      | 28.7964      | 9        |
| 2024-01-09 | Brazil  | Cereal     | 44.575     | 50.8155      | 8        |
| 2024-01-14 | Brazil  | Snacks     | 20.185     |              | 4        |
|            | Brazil  | Cosmetics  | 40.485     | 46.1529      | 2        |

You can use the LEFT function like

```
LEFT(VALUE([CATEGORY]), 2)
```

The new calculated column "Text" will return

| ORDER DATE | COUNTRY | CATEGORY   | UNIT PRICE | MARKET PRICE | QUANTITY | TEXT |
|------------|---------|------------|------------|--------------|----------|------|
| 03-01-2024 | Brazil  | Baby Food  | 38.41      | 43.7874      | 2        | Ba   |
| 07-01-2024 | Japan   | Spices     | 45.56      | 50.8155      | 20       | Sp   |
|            | Japan   |            |            | 43.7874      | 10       |      |
| 18-01-2024 |         |            |            | 32.3019      | 4        |      |
| 22-01-2024 | Brazil  | Cosmetics  | 28.335     | 23.0109      | 7        | Co   |
| 26-01-2024 | Canada  |            | 20.185     | 23.0109      | 9        |      |
| 04-01-2024 | France  | Cereal     | 25.26      | 28.7964      | 9        | Ce   |
| 09-01-2024 | Brazil  | Cereal     | 44.575     | 50.8155      | 8        | Ce   |
| 14-01-2024 | Brazil  | Snacks     | 20.185     |              | 4        | Sn   |
|            | Brazil  | Cosmetics  | 40.485     | 46.1529      | 2        | Co   |

