<?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: Percentage of customers who purchased again after a certain period of time in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Percentage-of-customers-who-purchased-again-after-a-certain/m-p/2960043#M98521</link>
    <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="484567" data-lia-user-login="yoyowes" class="lia-mention lia-mention-user"&gt;yoyowes&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not so sure about your expectation.&amp;nbsp; You may try to create a measure with this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ReturnPct = 
VAR CurrentMonth = MAX(TableName[Month-Year])
VAR CurrentClient =
COUNTROWS(
    FILTER(
        TableName,
        TableName[Month-Year] = CurrentMonth
        )
    )
VAR StartDate =
MINX(
    FILTER(DateTable, DateTable[Month]=CurrentMonth),
    'DateTable'[Date]
)
VAR HistoryClient =
COUNTROWS(
    FILTER(
        ALL(TableName),
        TableName[OrderDate]&amp;gt;=StartDate-400&amp;amp;&amp;amp;TableName[OrderDate]&amp;lt;=StartDate-300
    )
)
RETURN
FORMAT(DIVIDE(CurrentClient, HistoryClient),"0.0%")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried and it worked like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Dec 2022 02:18:03 GMT</pubDate>
    <dc:creator>FreemanZ</dc:creator>
    <dc:date>2022-12-10T02:18:03Z</dc:date>
    <item>
      <title>Percentage of customers who purchased again after a certain period of time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Percentage-of-customers-who-purchased-again-after-a-certain/m-p/2959726#M98502</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I am trying to calculate the percentage of customers who purchased again from 300 to 400 days after their first order&lt;BR /&gt;My data model looks like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;So if customers first purchased at january 2021, i need to find their future orders from november 2021 to february 2022, count the number of clients, and divide it by the nubmer of clients in january 2021&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to have this kind of table and have a product slicer:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know how to calculate this if i have second purchase date at the same month future year,&lt;/P&gt;&lt;P&gt;but i can`t figure out what to do with custom period&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2022 19:03:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Percentage-of-customers-who-purchased-again-after-a-certain/m-p/2959726#M98502</guid>
      <dc:creator>yoyowes</dc:creator>
      <dc:date>2022-12-09T19:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage of customers who purchased again after a certain period of time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Percentage-of-customers-who-purchased-again-after-a-certain/m-p/2960043#M98521</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="484567" data-lia-user-login="yoyowes" class="lia-mention lia-mention-user"&gt;yoyowes&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not so sure about your expectation.&amp;nbsp; You may try to create a measure with this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ReturnPct = 
VAR CurrentMonth = MAX(TableName[Month-Year])
VAR CurrentClient =
COUNTROWS(
    FILTER(
        TableName,
        TableName[Month-Year] = CurrentMonth
        )
    )
VAR StartDate =
MINX(
    FILTER(DateTable, DateTable[Month]=CurrentMonth),
    'DateTable'[Date]
)
VAR HistoryClient =
COUNTROWS(
    FILTER(
        ALL(TableName),
        TableName[OrderDate]&amp;gt;=StartDate-400&amp;amp;&amp;amp;TableName[OrderDate]&amp;lt;=StartDate-300
    )
)
RETURN
FORMAT(DIVIDE(CurrentClient, HistoryClient),"0.0%")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried and it worked like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Dec 2022 02:18:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Percentage-of-customers-who-purchased-again-after-a-certain/m-p/2960043#M98521</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2022-12-10T02:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage of customers who purchased again after a certain period of time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Percentage-of-customers-who-purchased-again-after-a-certain/m-p/2961230#M98640</link>
      <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="484567" data-lia-user-login="yoyowes" class="lia-mention lia-mention-user"&gt;yoyowes&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, you want to "&lt;SPAN&gt;calculate the percentage of customers who purchased again from 300 to 400 days after their first order&lt;/SPAN&gt;". Right?&lt;/P&gt;
&lt;P&gt;Here are the steps you can refer to :&lt;BR /&gt;(1)This is my test data :&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;(2)We can create a calendar table and we do not need to create relationship between two tables:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Table = CALENDAR(FIRSTDATE('Order'[Order date]), LASTDATE( 'Order'[Order date]))&lt;/LI-CODE&gt;
&lt;P&gt;(3)Then we can create a measure :&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = var _cur_date = MIN('Table'[Date])
var _cur_customer  =DISTINCT(SELECTCOLUMNS( FILTER('Order' , YEAR('Order'[Order date]) = YEAR(_cur_date) &amp;amp;&amp;amp; MONTH('Order'[Order date]) = MONTH(_cur_date)), "Customer" , [Customer]))
var _after_first_date =IF(_cur_date&amp;lt;&amp;gt; BLANK(), EOMONTH(_cur_date , 9)+1)
var _after_last_date  =IF(_cur_date&amp;lt;&amp;gt; BLANK(), EOMONTH(_cur_date , 12)+1)
var _after_customer =SELECTCOLUMNS( FILTER('Order' , 'Order'[Order date]&amp;gt;= _after_first_date &amp;amp;&amp;amp; 'Order'[Order date] &amp;lt;= _after_last_date) , "Customer" , [Customer])
var _same_customer =COUNTROWS( DISTINCT(INTERSECT(_after_customer,_cur_customer)))
var _cur_total = COUNTROWS(_cur_customer)
return
DIVIDE(_same_customer,_cur_total)&lt;/LI-CODE&gt;
&lt;P&gt;(4)Then we can put the fields we need on the visual and we can meet your need:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Aniya Zhang&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; it as the solution&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 02:28:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Percentage-of-customers-who-purchased-again-after-a-certain/m-p/2961230#M98640</guid>
      <dc:creator>v-yueyunzh-msft</dc:creator>
      <dc:date>2022-12-12T02:28:06Z</dc:date>
    </item>
  </channel>
</rss>

