<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Extract first unique customer ID in a given month (cohort analysis) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-first-unique-customer-ID-in-a-given-month-cohort/m-p/2107436#M48165</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;In my scenario I would like to track down a customer's first purchase in a month and avoid any duplicates if the customer has multiple purchases in one day. The reason for this is that I would like to create a visualization like the one seen in the tooltip below, but just with the right numbers:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Sep 2021 06:59:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-09-30T06:59:47Z</dc:date>
    <item>
      <title>Extract first unique customer ID in a given month (cohort analysis)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-first-unique-customer-ID-in-a-given-month-cohort/m-p/2106534#M48132</link>
      <description>&lt;P&gt;Hi Everyone.&amp;nbsp;&lt;BR /&gt;I am currently working on a cohort analysis in PowerBI, where I would like to show when the different customers from a given cohort starts to buy again. I have currently setup the cohort analysis in a matrix, which is working fine,&amp;nbsp; but I have trouble to calculate the time when a customer makes a purchase again. To give you a better understand of the current setup, then take a look at the snippet below.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;As you can see is the total of the number of customer retention being calculated correctly, but if we aggregate the data on to dates (in this scenario primo, medio, ultimo) on the given month, then it counts an unique customer id multiple time.&amp;nbsp;&lt;BR /&gt;What I want to achive is, when an unique customer ID has appeared once in the given month, then it should only count the first time it appears (eg. only count when a customer made first purchase the 2th and not the 10th).&amp;nbsp;&lt;BR /&gt;My current DAX for the "Customer Retention num" looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Customer Retention num = 
VAR CurrentMonthAfter = SELECTEDVALUE('Months After'[Value]) 
# Value is a generated serie (GENERATESERIES(0,12,1)) which specifies the months after the observed month
VAR CurrentFirstOrderMonth = SELECTEDVALUE(CustomerID_Table[First Order Date (EDM)]) 
# First order date is a coloum given by the following dax

# VAR CurrentCustomer = CustomerID_Table[customerID]
# RETURN
# CALCULATE(
#    EOMONTH(MIN(CustomerID_Table[date]),0),
#    FILTER(
#        CustomerID_Table,
#        CustomerID_Table[customerID] = CurrentCustomer
#    )
#)

RETURN 
    CALCULATE(
        DISTINCTCOUNT(CustomerID_Table[customerID]),
        FILTER(
            CustomerID_Table,
            EOMONTH(CustomerID_Table[date],0) = EOMONTH(CurrentFirstOrderMonth, CurrentMonthAfter)
            )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope my case makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards&amp;nbsp;&lt;BR /&gt;Jakob&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 19:58:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-first-unique-customer-ID-in-a-given-month-cohort/m-p/2106534#M48132</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-29T19:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Extract first unique customer ID in a given month (cohort analysis)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-first-unique-customer-ID-in-a-given-month-cohort/m-p/2107155#M48153</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt; , First sales is first sales in the month or overall ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have done something similar in the blog&lt;/P&gt;
&lt;P&gt;Customer Retention Part 3: Period Of Stay – Cohort Analysis: &lt;A href="https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-3-Period-Of-Stay-Cohort-Analysis/ba-p/1393410" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-3-Period-Of-Stay-Cohort-Analysis/ba-p/1393410&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 04:42:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-first-unique-customer-ID-in-a-given-month-cohort/m-p/2107155#M48153</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2021-09-30T04:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Extract first unique customer ID in a given month (cohort analysis)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-first-unique-customer-ID-in-a-given-month-cohort/m-p/2107436#M48165</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;In my scenario I would like to track down a customer's first purchase in a month and avoid any duplicates if the customer has multiple purchases in one day. The reason for this is that I would like to create a visualization like the one seen in the tooltip below, but just with the right numbers:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 06:59:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-first-unique-customer-ID-in-a-given-month-cohort/m-p/2107436#M48165</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-30T06:59:47Z</dc:date>
    </item>
  </channel>
</rss>

