# Custom Measure

## Overview

A **Custom Measure** in ReOrc enables users to create new numerical calculations within a Cube, enhancing data analysis and reporting capabilities. These measures help define key business metrics that may not exist explicitly in the raw dataset.

## What is Custom Measure?

A **Custom Measure** is a user-defined metric derived from existing fields using aggregation, mathematical operations, or conditional logic. These measures help refine insights and provide additional flexibility in data analysis.

## Use Cases

* **New Business Metrics**: Defining KPIs such as "Profit Margin" using (`(Revenue - Cost) / Revenue`).
* **Conditional Aggregations**: Creating measures like "High-Value Orders" for transactions above a certain amount.
* **Ratio & Percentage Calculations**: Computing values like "Conversion Rate" as (`(Total Sales / Total Visitors) * 100`).
* **Custom Weighting**: Applying business rules to weigh certain values differently in calculations.

## Create a Custom Measure

To create a custom dimension, follow these steps:

{% hint style="info" %}
Ensure the cube's primary key has been set before proceed to create the custom dimension. Refer [#create-cube](https://docs.reorc.com/semantic-modeling/cube/..#create-cube "mention")
{% endhint %}

1. Click on **+** button, select **Add a measure**

<figure><img src="https://786945529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFTrGKWnjusKCQj11CkuL%2Fuploads%2FGDHukXCvxDz7KNaOcqzZ%2Fimage.png?alt=media&#x26;token=e5d587ba-88cf-45bd-962c-7109bd568a58" alt=""><figcaption></figcaption></figure>

2. Fill in the details in the modal:

   1. **Field label** will be auto populate based on the Field name&#x20;
   2. When entering the **custom formula**, you can click on the fields on the list to auto populate into the formula box.
   3. For **Aggregations** and sample use case, refer to [aggregation-function](https://docs.reorc.com/semantic-modeling/cube/custom-measure/aggregation-function "mention")

   <figure><img src="https://786945529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFTrGKWnjusKCQj11CkuL%2Fuploads%2Fs2gTfnEb8JbcrYlh9F4R%2Fimage.png?alt=media&#x26;token=df2d60fb-f824-42e7-b0b9-34a7d2ab2710" alt=""><figcaption></figcaption></figure>
3. Click on **Validate** button to validate the formula

{% hint style="warning" %}
Ensure that the custom formula matches the type of database connected.
{% endhint %}

4. Once no error detected, click on **Add** button to add the custom dimension into the cube.
