<?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: Intersection - Retention Rate in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Intersection-Retention-Rate/m-p/1054941#M14531</link>
    <description>&lt;P&gt;Assuming you have Oct/Nov/Dec data for this measure to work for Jan/Feb/Mar, I am not sure why you need the Retention Rate 2 DAX.&amp;nbsp; It looks like you have all you need in the Retention Rate 1 part.&amp;nbsp; Would this work if you used it in your Return?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Return&lt;/P&gt;&lt;P&gt;Divide(Countrows(Intersection); Countrows(&lt;SPAN&gt;varActiveCustomers90days))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Pat&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Apr 2020 01:40:16 GMT</pubDate>
    <dc:creator>mahoneypat</dc:creator>
    <dc:date>2020-04-29T01:40:16Z</dc:date>
    <item>
      <title>Intersection - Retention Rate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Intersection-Retention-Rate/m-p/1054891#M14527</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I need to create a graph to show customer retention rate. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'll give an example of the rational behind this KPI&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If I want the retention rate for April this year, I need to look at all the different customers with purchases in the last 3 months (April, March and February) and compare with the customers before that period that would be January. So if 500 customers bought between Apr / Mar / Feb and of those 500, 420 had also bought in January, the retention rate is 420/500 = 84%. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then I always need to compare the intersection between customers with purchases in the last 3 months with the previous month.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I had created 2 measures:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Retention Rate 1 =&lt;/STRONG&gt;&lt;BR /&gt;VAR varHighMonthSelected90days = SELECTEDVALUE(Date[FirstdayofMonth])&lt;BR /&gt;VAR varLowMonthSelected90days = DATEADD(Date[FirstdayofMonth];-2;MONTH)&lt;BR /&gt;VAR varPreviousMonthSelected90days = DATEADD(Date[FirstdayofMonth];-3;MONTH)&lt;/P&gt;&lt;P&gt;--&lt;SPAN&gt;Returns a table with a column with all customers who purchased within 90 days&lt;/SPAN&gt;--&lt;BR /&gt;VAR varActiveCustomers90days =&lt;BR /&gt;CALCULATETABLE(VALUES('Account'[AccountNumber]);&lt;BR /&gt;'Date'[FirstdayofMonth]&amp;gt;=varLowMonthSelected90days&amp;nbsp;&amp;amp;&amp;amp;&lt;BR /&gt;'Date'[FirstdayofMonth]&amp;lt;=varHighMonthSelected90days&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;--&lt;SPAN&gt;Returns a table with a column with all customers who bought in the period of 1 month prior to 90 days&lt;/SPAN&gt;--&lt;BR /&gt;VAR var&lt;SPAN&gt;CustomersActiveMonthPreviousPeriod90Days&lt;/SPAN&gt;=&lt;BR /&gt;CALCULATETABLE(VALUES('Account'[AccountNumber]);&lt;BR /&gt;'Date'[FirstdayofMonth]=varPreviousMonthSelected90days&lt;BR /&gt;)&lt;BR /&gt;--&lt;SPAN&gt;Returns the Intersection between the two tables&lt;/SPAN&gt;--&lt;BR /&gt;VAR Intersection = INTERSECT(varActiveCustomers90days;var&lt;SPAN&gt;CustomersActiveMonthPreviousPeriod90Days&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;COUNTROWS(Intersection)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Retention Rate 2 =&lt;/STRONG&gt;&lt;BR /&gt;VAR varPreviousMonthSelected90days = DATEADD(Date[FirstdayofMonth];-3;MONTH)&lt;/P&gt;&lt;P&gt;--&lt;SPAN&gt;Returns a table with a column with all customers who bought in the period of 1 month prior to 90 days&lt;/SPAN&gt;--&lt;BR /&gt;VAR var&lt;SPAN&gt;CustomersActiveMonthPreviousPeriod90Days&lt;/SPAN&gt;=&lt;BR /&gt;CALCULATETABLE(VALUES('Account'[AccountNumber]);&lt;BR /&gt;'Date'[FirstdayofMonth]=varPreviousMonthSelected90days&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;DIVIDE([Retention Rate 1];COUNTROWS(var&lt;SPAN&gt;CustomersActiveMonthPreviousPeriod90Days&lt;/SPAN&gt;))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;U&gt;&lt;STRONG&gt;However, this formula is not working for the beginning of this year (jan/feb/mar). That way, I can't create a chart either, just an indicator according to the month I select. Can anyone help me please?&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 01:08:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Intersection-Retention-Rate/m-p/1054891#M14527</guid>
      <dc:creator>nathov</dc:creator>
      <dc:date>2020-04-29T01:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: Intersection - Retention Rate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Intersection-Retention-Rate/m-p/1054941#M14531</link>
      <description>&lt;P&gt;Assuming you have Oct/Nov/Dec data for this measure to work for Jan/Feb/Mar, I am not sure why you need the Retention Rate 2 DAX.&amp;nbsp; It looks like you have all you need in the Retention Rate 1 part.&amp;nbsp; Would this work if you used it in your Return?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Return&lt;/P&gt;&lt;P&gt;Divide(Countrows(Intersection); Countrows(&lt;SPAN&gt;varActiveCustomers90days))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Pat&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 01:40:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Intersection-Retention-Rate/m-p/1054941#M14531</guid>
      <dc:creator>mahoneypat</dc:creator>
      <dc:date>2020-04-29T01:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Intersection - Retention Rate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Intersection-Retention-Rate/m-p/1056585#M14583</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="226208" data-lia-user-login="mahoneypat" class="lia-mention lia-mention-user"&gt;mahoneypat&lt;/a&gt;&amp;nbsp;thank you, you're right! I can have all in only one formula but it still doesn't working:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Retention Rate =&lt;/STRONG&gt;&lt;BR /&gt;VAR varHighMonthSelected90days = SELECTEDVALUE(Date[FirstdayofMonth])&lt;BR /&gt;VAR varLowMonthSelected90days = DATEADD(Date[FirstdayofMonth];-2;MONTH)&lt;BR /&gt;VAR varPreviousMonthSelected90days = DATEADD(Date[FirstdayofMonth];-3;MONTH)&lt;/P&gt;&lt;P&gt;--&lt;SPAN&gt;Returns a table with a column with all customers who purchased within 90 days&lt;/SPAN&gt;--&lt;BR /&gt;VAR varActiveCustomers90days =&lt;BR /&gt;CALCULATETABLE(VALUES('Account'[AccountNumber]);&lt;BR /&gt;'Date'[FirstdayofMonth]&amp;gt;=varLowMonthSelected90days&amp;nbsp;&amp;amp;&amp;amp;&lt;BR /&gt;'Date'[FirstdayofMonth]&amp;lt;=varHighMonthSelected90days&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;--&lt;SPAN&gt;Returns a table with a column with all customers who bought in the period of 1 month prior to 90 days&lt;/SPAN&gt;--&lt;BR /&gt;VAR var&lt;SPAN&gt;CustomersActiveMonthPreviousPeriod90Days&lt;/SPAN&gt;=&lt;BR /&gt;CALCULATETABLE(VALUES('Account'[AccountNumber]);&lt;BR /&gt;'Date'[FirstdayofMonth]=varPreviousMonthSelected90days&lt;BR /&gt;)&lt;BR /&gt;--&lt;SPAN&gt;Returns the Intersection between the two tables&lt;/SPAN&gt;--&lt;BR /&gt;VAR Intersection = INTERSECT(varActiveCustomers90days;var&lt;SPAN&gt;CustomersActiveMonthPreviousPeriod90Days&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;DIVIDE(COUNTROWS(Intersection);COUNTROWS(var&lt;SPAN&gt;CustomersActiveMonthPreviousPeriod90Days&lt;/SPAN&gt;))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This formula still doesn't work for the beggining of this year (jan/feb/mar), assuming that I have 2019 data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="54293" data-lia-user-login="v-yuta-msft" class="lia-mention lia-mention-user"&gt;v-yuta-msft&lt;/a&gt;&amp;nbsp;can you please try to help me? You've already helped me with something similar befora. Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 13:35:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Intersection-Retention-Rate/m-p/1056585#M14583</guid>
      <dc:creator>nathov</dc:creator>
      <dc:date>2020-04-29T13:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Intersection - Retention Rate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Intersection-Retention-Rate/m-p/1064128#M14851</link>
      <description>&lt;P&gt;Here's the measure:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// Assumptions:
// 1. There's a dimension that stores Customers.
// 2. There's a fact table, Sales, that joins on
// 	  CustomerId to Customers and Date to Calendar.
// 3. There's a dimension Calendar which is a proper
//	  calendar in the model (marked as such).

[Retention Rate] =
var __lastVisibleDate = LASTDATE( 'Calendar'[Date] )
var __shouldCalculate =
	// You can calculate the ratio only when
	// you can go back in time 4 months from
	// __lastVisibleDate.
	NOT(
		ISBLANK( NEXTDAY( DATEADD(__lastVisibleDate, -4, month ) ) )
		&amp;amp;&amp;amp;
		ISBLANK( DATEADD( NEXTDAY( __lastVisibleDate ), -4, month ) )
	)
var __result =
	if( __shouldCalculate, 
	
		var __custWithPurchWithinLast3Months =
			CALCULATETABLE(
				VALUES( Sales[CustomerID] ),
				DATESINPERIOD(
					'Calendar'[Date],
					__lastVisibleDate,
					-3,
					MONTH
				)
			)
		var __lastVisibleDateMinus3Months =
			dateadd( __lastVisibleDate, -3, month )
		var __custWithPurch1MonthBeforeLast3Months =
			CALCULATETABLE(
				VALUES( Sales[CustomerID] ),
				DATESINPERIOD(
					'Calendar'[Date],
					__lastVisibleDateMinus3Months,
					-1,
					MONTH
				)
			)
		var __custThatBoughtInBothPeriods =
			INTERSECT(
				__custWithPurchWithinLast3Months,
				__custWithPurch1MonthBeforeLast3Months
			)
		var __ratio =
			DIVIDE(
				countrows( __custThatBoughtInBothPeriods ),
				COUNTROWS( __custWithPurchWithinLast3Months )
			)			
		return
			__ratio
	)
RETURN
	__result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please bear in mind that this works for ANY SELECTED PERIOD OF TIME, not only for months.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Sun, 03 May 2020 11:53:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Intersection-Retention-Rate/m-p/1064128#M14851</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-03T11:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Intersection - Retention Rate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Intersection-Retention-Rate/m-p/1067905#M14945</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;thank you very much for your help!!!!&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 21:19:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Intersection-Retention-Rate/m-p/1067905#M14945</guid>
      <dc:creator>nathov</dc:creator>
      <dc:date>2020-05-04T21:19:43Z</dc:date>
    </item>
  </channel>
</rss>

