Skip to main content

Creating the prod_customer_ltv Model

This model will calculate the lifetime value of customers. Let's see how we want this to finally look like:

img prod_customer_ltv Prod Customer LTV

As you can see, for each customer ID, we have the customer ID, the customer's first name, last name, first order date, last order date, total orders, total amount spent by the customer. We have all the intermediate models to calculate this, but we need to join them to get the final result. No aggregation is needed in this model.

Specifying model dependencies

This model is a dependent of the stg_order_summaries, stg_aggr_order_payments, stg_payments_by_type, and dev_customers models. To create a new model, we'll right-click on the no-code folder in the left sidebar and select New Model. For Heirarchy, we'll select Child Of, rather than Root model and specify this mode's dependencies: stg_order_summaries, stg_aggr_order_payments, stg_payments_by_type, and dev_customers.

img prod_customer_ltv New Model

Setting up the joins

To get the information we need, we'll need to join the dev_customers model with the stg_order_summaries and the stg_aggr_order_payments models on the customer_id column. Let's see how to do that.

img prod_customer_ltv Joins

Clicking on Apply will create the joins and you can now see the joined data in the data grid.

Setting up the transformations

As discussed before, we need to add a sort by customer_id.

img prod_customer_ltv Sort

Clicking on Sort will create the sort and you should now see the sorted data in the data grid.

The final model

Let's look at the final model (same as we saw in the beginning).

img prod_customer_ltv Final

Next Steps

This brings us to the end of the transforms definition part of the Quick Start Guide for No-Code. We have created all the models we need to get started with No-Code. Without writing any code, we've transformed the raw data into useful models. We can now use these models to create dashboards, reports, and more.

But, before we can do that, we'll need to deploy and run our models. Let's see how to do that in the next section.