> For the complete documentation index, see [llms.txt](https://help.daasity.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.daasity.com/technical-docs/transform-code/transform-code/life-time-value-code.md).

# Life-Time Value Code

This page provides detailed instructions on the Life-Time Value Code transform code block and what should be added to the Script Manifest file in order to execute the code

## Script Manifest File (YML)

### Upstream Transformation Dependencies

{% hint style="warning" %}
This code block is dependent on the following upstream code blocks being implemented:

* Initialization
* UOS
* Order Status
* Order Channel and Marketing
* Order and Order Line Revenue
* Customer
  {% endhint %}

### Transformation Code Requirements

The following code should be added to the main workflow in the appropriate position, after Reviews and before Returns per the [Transform Code Sequence - DRP](https://help.daasity.com/technical-docs/transform-code/transform-code/transform-code-sequence-drp.md) page

```
  #--------------------------------------------------------------------------------------------------------------------
  # SECTION: 5100_LTV
  # DEPENDENCIES:
  #   - Section: 0500_UOS
  #   - Section: 2700_ORDER_STATUS
  #   - Section: 4300_ORDER_LINE_REVENUE
  #   - Section: 4600_CUSTOMER
  # REQUIRED: No
  # PURPOSE: This code the DRP tables for life time value and customer segments and should be enabled once the
  # upstream blocks are enabled
  #--------------------------------------------------------------------------------------------------------------------
  ltv and segments:
    integrations:
    scripts:
      - "github://platform-sql-shared/scripts/pro/5100_life_time_value/5110_LTV_BAS_ltv_time_series.sql"
      - "github://platform-sql-shared/scripts/base/5100_life_time_value/5120_LTV_BAS_ltv_cac.sql"
```

### Life-Time Value

{% hint style="success" %}
Add this code to enable LTV analysis and determine LTV to CAC ratios by creating the following tables:

* \[`drp.ltv_time_series`]
* \[`drp.ltv_cac`]
  {% endhint %}

Create the \[`drp.ltv_time_series`] table

* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/pro/5100_life_time_value/5110_LTV_BAS_ltv_time_series.sql>

Create the \[`drp.ltv_cac`] table

* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/5100_life_time_value/5120_LTV_BAS_ltv_cac.sql>
