an-lisis-de-cohortes
Cohort retention analysis — how groups of users or customers behave over time after an initial event
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Cohort retention analysis — how groups of users or customers behave over time after an initial event
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Sequence cleaning steps in a chain — trim/case/replace, null handling, deduplication, and type casting — in the right order. Use when raw ingested data needs cleaning before joins or aggregation.
Place Assert and Schema Validation nodes as gates that halt a chain when data is wrong, so bad data never reaches the output. Use when the pipeline must guarantee correctness before exporting or loading downstream.
Choose the right sink format, compression, and destination for a chain's output, and decide between exporting a file vs creating a table. Use at the end of a pipeline when deciding how to persist results.
Best practices for loading files into a chain — single file, folder globs, type detection, and union of many files. Use when the pipeline starts from CSV/Parquet/JSON/Excel files or a folder of files.
Decide between Merge (stack rows / UNION) and Join (match on a key) when a chain has multiple inputs, and set keys and join type correctly. Use when a pipeline combines two or more upstream tables.
Descompone un objetivo de procesamiento en un flujo de nodos Chains (source → transform → sink). Use when the user wants to build a data pipeline / chain, or describes an end-to-end "load X, clean it, summarize, export" goal.
| name | Análisis de Cohortes |
| description | Cohort retention analysis — how groups of users or customers behave over time after an initial event |
| keywords | cohort, retention, churn, lifetime, ltv, funnel, conversion, cohorte, retención, retencion, vuelven, retornan, regresan, abandono, grupos, segmento |
| next | data-storytelling |
Activa cuando el análisis requiere comparar grupos definidos por un evento de inicio (primera compra, registro, etc.) y rastrear su comportamiento a lo largo del tiempo.
El SQL de abajo es una plantilla canónica deliberada — el patrón de cohortes es frágil, así que síguela de cerca. Lo que sí es decisión de juicio es qué define la cohorte (paso 1): el evento de inicio, la granularidad y la métrica de éxito cambian todo el análisis. Si es ambiguo, pregunta antes de asumir.
WITH cohortes AS (
SELECT user_id,
DATE_TRUNC('month', MIN(fecha_evento)) AS mes_cohorte
FROM eventos
GROUP BY user_id
),
actividad AS (
SELECT e.user_id,
c.mes_cohorte,
DATE_TRUNC('month', e.fecha_evento) AS mes_actividad,
DATEDIFF('month', c.mes_cohorte, DATE_TRUNC('month', e.fecha_evento)) AS mes_numero
FROM eventos e
JOIN cohortes c USING (user_id)
)
SELECT mes_cohorte, mes_numero,
COUNT(DISTINCT user_id) AS usuarios_activos
FROM actividad
GROUP BY mes_cohorte, mes_numero
ORDER BY mes_cohorte, mes_numero
display_chart tipo heatmap (mes_cohorte en Y, mes_numero en X, tasa de retención como valor)final_answer con: tasa de retención promedio por período, cohorte con mejor/peor desempeño, tendencia de mejora o deterioroDATE_TRUNC('month', ...) a DATE_TRUNC('week', ...)