> For the complete documentation index, see [llms.txt](https://presight.gitbook.io/presight-v1.0/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://presight.gitbook.io/presight-v1.0/introduction/core-concepts/segments/custom-segments.md).

# Custom Segments

In data analysis, raw data often requires transformation to extract meaningful insights. **Custom segments** are powerful tools that allow you to create new groupings or categories based on logical expressions applied to existing raw data fields. By using custom segments, you can manipulate and enhance your data to align with specific analytical needs, enabling more nuanced and insightful analysis.

## **What is a Custom Segment?**

A **custom segment** is a new grouping that you create by applying calculations, transformations, or logical expressions to one or more existing data fields in your dataset. This process involves defining an expression or condition that combines or filters the data from the raw fields to produce a new categorized subset.

Custom segments serve as a way to:

* **Transform Data**: Reorganize raw data into more meaningful groups.
* **Perform Calculations**: Compute new metrics or indicators based on specific criteria.
* **Categorize Data**: Group data into segments based on defined rules or conditions.
* **Enhance Analysis**: Provide additional perspectives for analysis that are not apparent in the raw data.

***

## **Example Use-cases**

### **1. Calculated Segments**

Create a custom segment that groups data based on calculated values from existing numerical fields.

**Example**: Segment products based on profit margin.

* **Calculation**: `(Revenue - Cost) / Revenue * 100`
* **Segments**:
  * **High Margin Products**: Profit margin > 30%
  * **Medium Margin Products**: Profit margin between 10% and 30%
  * **Low Margin Products**: Profit margin < 10%

### **2. Data Transformation**

Modify or create segments based on transformations of existing data fields.

**Example**: Segment transactions by year extracted from a date field to analyze annual trends.

* **Transformation**: Extract `YEAR(Order Date)`
* **Segments**: Group transactions by each year.

### **3. Conditional Logic**

Create segments based on specific conditions applied to your data.

**Example**: Categorize customers based on their total spend.

* **Conditions**:

  ```mathematica
  IF(Total Spend > 5000, "Platinum",
     IF(Total Spend > 2000, "Gold",
        IF(Total Spend > 1000, "Silver", "Bronze")))
  ```
* **Segments**: Assign customers to "Platinum," "Gold," "Silver," or "Bronze" categories.

### **4. Combining Attributes**

Create segments by combining values from multiple data fields.

**Example**: Segment customers by combining their geographic location and purchase behavior.

* **Combination**: `Region = "North America" && Purchase Frequency = "High"`
* **Segments**: "North-America-High Frequency", "Others".

***

## **How to Create Custom Segments**

While the specific steps may vary depending on the data analysis tool you are using, creating custom segments generally involves:

### **1. Column Creator**

The **Column Creator** is a straightforward tool that allows you to add new segments directly within your existing data tables. With its intuitive interface, you can build custom segments by applying business rules and calculations without needing technical expertise. These custom segments seamlessly integrate into your data tables and are ready to be used across analyses and reports.

{% content-ref url="/pages/OKSpqVQ03jV9mxEl7UJu" %}
[Creating a new Dimension](/presight-v1.0/dimension/creating-a-new-dimension.md)
{% endcontent-ref %}

### **2. Table Builder**

The **Table Builder** provides a flexible environment to create new tables with custom segments, conditions, and filters. It offers an Excel-like experience, utilizing familiar formula expressions to define custom segments and making data manipulation accessible. You can combine and transform data from multiple sources, performing advanced calculations and aggregations to generate new insights tailored to your analytical needs.

{% content-ref url="/pages/tiNNYHsa5ZuTLOLi2APg" %}
[Table Builder](/presight-v1.0/model/custom-tables/table-builder.md)
{% endcontent-ref %}

### **3. Using Formulas**

Presight's **Breakdown** **Formula** feature allows you to create custom segments on the fly within your analyses and reports. You can define dynamic calculations and custom expressions directly within your reports, adapting your analyses in real-time to address immediate business questions. By leveraging a wide range of mathematical, statistical, and logical functions, you can derive new metrics and enhance your data analysis without altering the underlying data tables.

###
