> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superjoin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Derived Columns Examples

> Explore practical examples of using derived columns to solve common data challenges, such as adjusting MRR with discounts, categorizing customers based on subscription duration, and identifying overdue invoices. These examples demonstrate how to apply mathematical, string, and date functions to derive actionable insights from your data.

### **Calculating Adjusted MRR**

* **Objective**: Adjust the Monthly Recurring Revenue (MRR) based on a given discount percentage.
* **Formula**: **`MRR * (1 - discount_percentage)`**
* **Example**: If a subscription with an **`MRR`** of **`$1200`** has a **`10%`** discount, the formula **`1200 * (1 - 0.10)`** calculates the adjusted MRR as **`$1080`**.

### **Segmenting Customers by Subscription Date**

* **Objective**: Categorize customers based on how long they have been subscribed.
* **Formula**: **`if(diff_days(today(), activated_at) > 365, "Long-term", "New")`**
* **Example**: This will label customers who have been active for more than a year as "Long-term" and others as "New".

### **Finding Overdue Invoices**

* **Objective**: Identify invoices that are past the due date.
* **Formula**: **`if(diff_days(due_date, today()) > 0, "Overdue", "On Time")`**
* **Example**: If **`due_date`** is **`2023-06-01`** and today is **`2024-02-20`**, **`diff_days(2023-06-01, today())`** would label the invoice as "Overdue".

### **Calculating Subscription Age**

* **Formula**: **`diff_days(today(), activated_at)`**
* **Description**: Calculate the number of days since a subscription was activated.
* **Usage**: To find out how long a customer has been active, use the **`activated_at`** column which contains the activation date of each subscription.
* **Example**: **`diff_days(today(), A2)`** where A2 contains the **`activated_at`** date for a subscription.

### **Categorizing Subscriptions Based on MRR**

* **Formula**: **`if(MRR >= 1000, "Enterprise", "SMB")`**
* **Description**: Categorize subscriptions into "Enterprise" or "SMB" based on MRR.
* **Usage**: To segment your customers based on their MRR, you can set a threshold that defines "Enterprise" level MRR.
* **Example**: **`if(B2 >= 1000, "Enterprise", "SMB")`** where B2 contains the **`MRR`** for a subscription.
