<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Himmet Kaplan on Medium]]></title>
        <description><![CDATA[Stories by Himmet Kaplan on Medium]]></description>
        <link>https://medium.com/@himmetkaplan?source=rss-d1e78cc21cd4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*0NEX_cwNBnLekWfD.</url>
            <title>Stories by Himmet Kaplan on Medium</title>
            <link>https://medium.com/@himmetkaplan?source=rss-d1e78cc21cd4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 14:29:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@himmetkaplan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Easily Create your Retention Cohort with SQL and Excel]]></title>
            <link>https://medium.com/@himmetkaplan/easily-create-your-retention-cohort-with-sql-and-excel-d4b9cfe75ff6?source=rss-d1e78cc21cd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4b9cfe75ff6</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[churn-rate]]></category>
            <category><![CDATA[cohort-analysis]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[retention]]></category>
            <dc:creator><![CDATA[Himmet Kaplan]]></dc:creator>
            <pubDate>Sun, 26 Jan 2020 22:18:28 GMT</pubDate>
            <atom:updated>2020-01-26T22:18:28.579Z</atom:updated>
            <content:encoded><![CDATA[<h3>Create your Retention Cohort with SQL</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vu0dJG902CK7anhhDK826g.jpeg" /><figcaption>Source: <a href="https://pt.depositphotos.com/">Depositphotos</a> #316452340</figcaption></figure><p>As you are here, you are already aware of what retention/churn means for your business so I am not going to explain the meaning in detail. However, I will mention about Cohort and different use cases which you can apply regarding your business cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*gznKNIeWD-wBg51qkV3VFg.png" /><figcaption>Source: Oxford Dictionary</figcaption></figure><p>In our cases, those people are our website visitors, app users or customers. Their common characteristics might be signing up, purchase, booking, app open or just a visit date.</p><p>USE CASE: E-COMMERCE PURCHASE RETENTION</p><p>I will consider the <em>purchase date as a cohort</em> and accept the <em>starting period as the first purchase month, cohort_month</em>. First, calculate the month difference between the first transaction and the following transactions. Once we have month difference and first purchase month, all we need to do is counting unique customers in each cell. Then, we have all the values needed. Dividing each cell to the first cohort provides us purchase retention rate for each month. Also, daily and weekly versions can be produced easily by modifying <em>DATE_TRUNC</em> and <em>EXTRACT</em> parts.</p><p><strong>Step I</strong></p><p>We need to list all customers with their transactions. Then calculate the time difference between first transaction date and following transaction dates. Window function easily allows us to calculate time difference.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a4e93b17f370ea928dadaf5f4835d63/href">https://medium.com/media/5a4e93b17f370ea928dadaf5f4835d63/href</a></iframe><p><strong>Step II</strong></p><p>Now we have all dimensions, that we need to count unique customer in each cell, including <em>cohort_month</em>, <em>retention_month</em> and <em>user_id</em> at one place. It’s time to count our unique users within given cohort and retention month!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d69c5660457e28c4237c30446cfd7729/href">https://medium.com/media/d69c5660457e28c4237c30446cfd7729/href</a></iframe><p><strong>Step III</strong></p><p>We need the percentage of purchased customers in retention months compared to first purchased month, <em>cohort_month</em>. Again, window function saves us with FIRST_VALUE function in dividing cohort months to following retention months</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/425e2b46b9f30fe7a11a6a03439dc4dc/href">https://medium.com/media/425e2b46b9f30fe7a11a6a03439dc4dc/href</a></iframe><p>In some cases, you might want to consider the cohort as a sign-up date and then purchase. Take your user/customer etc. table with signup date and LEFT JOIN transaction/booking etc. table into it. In this case use signup date as cohort_month rather than MIN(created_at). This will also help you to understand signup to sales conversion and first sales cycle length. Also, if you need churn cohort rather than retention cohort use 1- (number_of_customer / <em>FIRST_VALUE</em>(number_of_customer) <strong>OVER </strong>(<strong>PARTITION BY </strong>cohort_month <strong>ORDER BY </strong>retention_month))</p><p><strong>RETENTION COHORT VISUALISATION:</strong></p><p>You should have your similar output to the one below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*xqgqSGyYc8WMPFE-5uJSHA.png" /></figure><p>If your BI tools support “Head Grid” type charts put cohort_month into Y-axes and retention_month into X-axes and lastly retention_rate as series. Also, some tools have built-in cohort charts like my favorites: Periscope and Rakam.io. I personally also love Tableau. You can also use pivot tables in Google spreadsheets or Excel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*Oe9dBbCVycc4G74n5LQTkg.png" /><figcaption>Retention cohort via Google Spreadsheet / Excel</figcaption></figure><p>Note: Queries for PostgreSQL.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4b9cfe75ff6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>