I wanted to show retention metric such as "Custome...
# gooddata-cloud
a
I wanted to show retention metric such as "Customer Retention", "Lifetime Value" etc. What is the best possible way of calculating it in Good Data?
k
To calculate retention metrics such as "Customer Retention" or "Lifetime Value" in GoodData, you need to leverage the platform's metric creation capabilities using MAQL (Multi-Dimension Analytical Query Language). Here are the best practices and approaches based on the available knowledge sources: ### 1. Data Model Preparation - Ensure your data model clearly relates customers to their transactions, memberships, or activities over time. - Include relevant date dimensions (e.g., day, week, month, year) and attributes such as customer ID, membership type, and transaction amount. - If you need to calculate retention at different frequencies (weekly, monthly, yearly), make sure your model exposes these granularities and includes a "Membership Frequency" attribute if applicable. This allows you to filter and aggregate at the required levels[Community Slack Discussion](https://gooddataconnect.slack.com/archives/C04S1MSLEAW/p1757591134377139?thread_ts=1757591134.377139&cid=C04S1MSLEAW). ### 2. Metric Creation - Use the Metric Editor or API to define your retention or lifetime value metrics. Metrics can be built from facts (e.g., transaction amounts) and attributes (e.g., customer IDs), and you can nest metrics for more complex calculations[Create Metrics](https://www.gooddata.com/docs/cloud/create-metrics/). - For "Customer Retention," you might define a metric that counts the number of customers who made a purchase in a previous period and again in the current period. For "Lifetime Value," you could sum the total value of transactions per customer. #### Example: Creating a Metric via API
Copy code
json {   "data": {     "attributes": {       "title": "Customer Lifetime Value",       "description": "Sum of all purchases per customer",       "content": {         "format": "$#,##0",         "maql": "SELECT SUM({fact/purchase_amount}) BY {attribute/customer_id}"       }     },     "id": "customer_lifetime_value",     "type": "metric"   } }
You can adjust the MAQL expression to fit your retention logic, such as filtering for repeat purchases or specific time windows[Create Metrics using API](https://www.gooddata.com/docs/cloud/create-metrics/create-metrics-using-api/). ### 3. Handling Different Retention Frequencies - GoodData does not support dynamic, row-level conditional filtering within a single metric (e.g., automatically switching between weekly, monthly, or yearly retention based on membership type). - The recommended approach is to create separate metrics for each frequency (weekly, monthly, yearly) and display them side by side in your dashboard. Alternatively, preprocess your data outside GoodData to align retention calculations with the correct frequency before loading it into the platform[Community Slack Discussion](https://gooddataconnect.slack.com/archives/C04S1MSLEAW/p1757591134377139?thread_ts=1757591134.377139&cid=C04S1MSLEAW). ### 4. Visualization - Use Analytical Designer to create visualizations and calculated metrics from your defined metrics. You can apply date filters at various granularities and compare metrics over time[Calculate Metrics in Visualizations](https://www.gooddata.com/docs/cloud/create-visualizations/calculated-measures-in-insights/). --- Summary: - Prepare your data model with the necessary relationships and date granularities. - Define retention and lifetime value metrics using MAQL in the Metric Editor or API. - For different retention frequencies, create separate metrics or preprocess your data. - Use Analytical Designer to visualize and further analyze your metrics. If you need more specific MAQL examples or guidance on structuring your data model, let me know!
a
The way I want it to work for example: A card metric for retention where I put a comparison with the previous period. It is like I can see that how many customers came in the previous period which is still with us in the current period. Currently, I think, its showing the retention only for the each period when we put a comparison but not comparing the two periods. Also, I don't want to use MAQL for specifics. This blocks the drilldown option.
y
Hi Aman, The built-in comparison feature in GoodData card metrics or headlines compares metric values between periods, not the retention of entities across periods. Achieving true retention analysis without MAQL may not be supported by the built-in comparison feature. Using MAQL for this purpose can block drilldown, as you noted. However, the recommended approach is to create separate metrics or insights for each period and display them side by side, or preprocess your data. Please let me know if this helps.
👍 1