# Random() Function

**YouTube:** [How to Use the Random () Function in Report Custom Columns](https://www.youtube.com/watch?v=IXP66-aFRog).

## How to Use the Random () Function in Report Custom Columns.

In this tutorial, we’ll learn how to use the **`Random` function** to generate random numbers in your report columns.

***

### Accessing the Expression Designer:

* Navigate to the **Reporting** section.
* Open the **Sales Register Detailed Report** or any **"Report".**
* Go to **Setup Column Attributes**.
* Here, you'll see a list of available columns that can be used to build expressions.
* Click on **"Add/Edit Expression Columns"** where you can write your expression using predefined functions.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FBiD7B0nHi6iarn4CKfDv%2FBill%20Setup%20column%20attribute.png?alt=media&#x26;token=a582faef-5c69-4eb5-ac56-48057aaab80b" alt=""><figcaption></figcaption></figure>

* Before adding the expression to the report, go to **Other Settings**.
* Ensure the **Script Editor** is set to **VBScript**.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FPgRPBYdOmbcuIH0PZ7sI%2FOther%20Setting%20-%20VB%20Print.png?alt=media&#x26;token=60981fe7-c38c-4bf4-a8d9-40a3289ddbd7" alt=""><figcaption></figcaption></figure>

* Click **Save**.
  * *Note: VBScript is the default for new configurations but always verify this setting.*

### Writing Your First Expression

* Every expression must start with the script header: **'#@LSCRIPT**

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2F6sCEhRlGWfBL2O3Tg0XY%2FBill%20Setup%20column%20attribute%20Default%20Script.png?alt=media&#x26;token=af5f02ec-c5a6-41e5-bf23-16e2265b02e7" alt=""><figcaption></figcaption></figure>

* Click the (+) Plus icon to create a new expression.
* Fill in the required fields:&#x20;
  * **Expression Name** – A unique name for your expression.
  * **Expression Type** – Choose either **Text** or **Numeric** depending on the expected output.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2Fh977fgiBXsXdFNTDVCu2%2FAdd%20New%20Expression.png?alt=media&#x26;token=b8d387d2-9d63-404e-a405-643d651cb67f" alt=""><figcaption></figcaption></figure>

### Creating a Simple RANDOM() Expression

* Double-click the new expression name to insert it into the script editor.
* Define the expression using the syntax:
  * **Expression Name** = RANDOM()

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FPLdVBN8TJIiWa5Rq8Vbo%2FExp_Formula.png?alt=media&#x26;token=00952f41-3758-4954-9eb6-2ed1a550bff2" alt=""><figcaption></figcaption></figure>

* Save the expression once defined.
* Scroll down and **check the box** beside the expression name to enable it.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2F5Fslj3X9HM8rratI8e0C%2FSetup%20Column%20Attribute.png?alt=media&#x26;token=2b740fd5-9057-4beb-b523-0700c86df9e2" alt=""><figcaption></figcaption></figure>

* Save and proceed to check the effect.
* **Refresh the report** to view the final result.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FShS3xVaWx8Cl9sikHwoh%2FRep-Imp.png?alt=media&#x26;token=1ca289c0-526f-49c7-a197-5b951555acb4" alt=""><figcaption></figcaption></figure>

***

### Output:

| Function Used | Purpose                       | Output Example                        |
| ------------- | ----------------------------- | ------------------------------------- |
| `Random()`    | Generate number from 0 to 100 | `83`, `25`, `47` (changes on refresh) |
