<?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: DAX - Last year customer retention in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Last-year-customer-retention/m-p/2599261#M75090</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="356338" data-lia-user-login="Diego_Vialle" class="lia-mention lia-mention-user"&gt;Diego_Vialle&lt;/a&gt; , You need measure like &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rolling 3 = &lt;BR /&gt;var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())&lt;BR /&gt;var _min = date(Year(_max), month(_max) -3, Day(_max))+1,&lt;BR /&gt;BLANK())&lt;BR /&gt;return&lt;BR /&gt;CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))&lt;/P&gt;
&lt;P&gt;rolling 3 last year = &lt;BR /&gt;var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())&lt;BR /&gt;var _max = date(Year(_max)-1, month(_max), Day(_max))&lt;BR /&gt;var _min = date(Year(_max), month(_max) -3, Day(_max))+1,&lt;BR /&gt;BLANK())&lt;BR /&gt;return&lt;BR /&gt;CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;retained = countx(values(Customer[Customer]), if(not(isblank([rolling 3 last year])) &amp;amp;&amp;amp; not(isblank([rolling 3])) , Customer[Customer], blank()))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;lost = countx(values(Customer[Customer]), if(not(isblank([rolling 3 last year])) &amp;amp;&amp;amp; (isblank([rolling 3])) , Customer[Customer], blank()))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;new = countx(values(Customer[Customer]), if((isblank([rolling 3 last year])) &amp;amp;&amp;amp; not(isblank([rolling 3])) , Customer[Customer], blank()))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Customer Retention Part 1:&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-1-Month-on-Month-Retention/ba-p/1361529" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-1-Month-on-Month-Retention/ba-p/1361529&lt;/A&gt;&lt;BR /&gt;Customer Retention Part 2: Period over Period Retention :&lt;A href="https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-2-Period-over-Period-Retention/ba-p/1377458" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-2-Period-over-Period-Retention/ba-p/1377458&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jun 2022 03:31:49 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2022-06-24T03:31:49Z</dc:date>
    <item>
      <title>DAX - Last year customer retention</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Last-year-customer-retention/m-p/2598947#M75061</link>
      <description>&lt;P&gt;I have a measure that calculates customer retention: customers who bought in the last 3 months. I need to bring the comparison of this measure from the previous year. I tried the formula below without success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;customer retention: customers who bought in the last 3 months.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Frequencia pedidos Trimestral = 
VAR AllOldCustomers =
    CALCULATETABLE (
        VALUES ( fVendas[Nome do PN] ),
        fVendas,
        fVendas[Data NF]
            &amp;lt; TODAY () - 90,
        fVendas[Documento] = "Nota fiscal de saída"
    )
VAR AllNewCustomers =
    CALCULATETABLE (
        VALUES ( fVendas[Nome do PN] ),
        fVendas[Data NF]
            &amp;lt; TODAY () ,
        fVendas[Documento] = "Nota fiscal de saída"
    )
RETURN
    COUNTROWS ( EXCEPT ( AllNewCustomers, AllOldCustomers ) )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;comparison of this measure from the previous year:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Frequencia pedidos Trimestral PY = 
VAR PreviousYearDate = DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) )

VAR AllOldCustomers =
    CALCULATETABLE (
        VALUES ( fVendas[Nome do PN] ),
        fVendas,
        fVendas[Data NF]
            &amp;lt; PreviousYearDate - 90,
        fVendas[Documento] = "Nota fiscal de saída"
    )
VAR AllNewCustomers =
    CALCULATETABLE (
        VALUES ( fVendas[Nome do PN] ),
        fVendas[Data NF]
            &amp;lt; PreviousYearDate ,
        fVendas[Documento] = "Nota fiscal de saída"
    )
RETURN
    IF ( ISBLANK ( ( COUNTROWS ( EXCEPT ( AllNewCustomers, AllOldCustomers ) ) ) ), 0, COUNTROWS ( EXCEPT ( AllNewCustomers, AllOldCustomers ) ) ) &lt;/LI-CODE&gt;&lt;P&gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 22:29:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Last-year-customer-retention/m-p/2598947#M75061</guid>
      <dc:creator>Diego_Vialle</dc:creator>
      <dc:date>2022-06-23T22:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: DAX - Last year customer retention</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Last-year-customer-retention/m-p/2599261#M75090</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="356338" data-lia-user-login="Diego_Vialle" class="lia-mention lia-mention-user"&gt;Diego_Vialle&lt;/a&gt; , You need measure like &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rolling 3 = &lt;BR /&gt;var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())&lt;BR /&gt;var _min = date(Year(_max), month(_max) -3, Day(_max))+1,&lt;BR /&gt;BLANK())&lt;BR /&gt;return&lt;BR /&gt;CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))&lt;/P&gt;
&lt;P&gt;rolling 3 last year = &lt;BR /&gt;var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())&lt;BR /&gt;var _max = date(Year(_max)-1, month(_max), Day(_max))&lt;BR /&gt;var _min = date(Year(_max), month(_max) -3, Day(_max))+1,&lt;BR /&gt;BLANK())&lt;BR /&gt;return&lt;BR /&gt;CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;retained = countx(values(Customer[Customer]), if(not(isblank([rolling 3 last year])) &amp;amp;&amp;amp; not(isblank([rolling 3])) , Customer[Customer], blank()))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;lost = countx(values(Customer[Customer]), if(not(isblank([rolling 3 last year])) &amp;amp;&amp;amp; (isblank([rolling 3])) , Customer[Customer], blank()))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;new = countx(values(Customer[Customer]), if((isblank([rolling 3 last year])) &amp;amp;&amp;amp; not(isblank([rolling 3])) , Customer[Customer], blank()))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Customer Retention Part 1:&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-1-Month-on-Month-Retention/ba-p/1361529" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-1-Month-on-Month-Retention/ba-p/1361529&lt;/A&gt;&lt;BR /&gt;Customer Retention Part 2: Period over Period Retention :&lt;A href="https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-2-Period-over-Period-Retention/ba-p/1377458" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-2-Period-over-Period-Retention/ba-p/1377458&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 03:31:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Last-year-customer-retention/m-p/2599261#M75090</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-06-24T03:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: DAX - Last year customer retention</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Last-year-customer-retention/m-p/2599291#M75093</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="356338" data-lia-user-login="Diego_Vialle" class="lia-mention lia-mention-user"&gt;Diego_Vialle&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;This should work. I see no problem except that this formula is not supposed to be sliced by date (which has no meaning). You can use it to flag customers or in a card visual. Here is the same formula with minor cozmatics&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Frequencia pedidos Trimestral PY =
VAR PreviousYearDate =
    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) )
VAR AllOldCustomers =
    CALCULATETABLE (
        VALUES ( fVendas[Nome do PN] ),
        fVendas[Data NF] &amp;lt; PreviousYearDate - 90,
        fVendas[Documento] = "Nota fiscal de saída"
    )
VAR AllNewCustomers =
    CALCULATETABLE (
        VALUES ( fVendas[Nome do PN] ),
        fVendas[Data NF] &amp;lt; PreviousYearDate,
        fVendas[Documento] = "Nota fiscal de saída"
    )
RETURN
    COALESCE ( COUNTROWS ( EXCEPT ( AllNewCustomers, AllOldCustomers ) ), 0 )&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 24 Jun 2022 04:14:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Last-year-customer-retention/m-p/2599291#M75093</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-06-24T04:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: DAX - Last year customer retention</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Last-year-customer-retention/m-p/2600666#M75149</link>
      <description>&lt;P&gt;You're right again, for this formula it doesn't make sense to have a date filter. I need another formula then for repeat customers.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 12:51:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Last-year-customer-retention/m-p/2600666#M75149</guid>
      <dc:creator>Diego_Vialle</dc:creator>
      <dc:date>2022-06-24T12:51:31Z</dc:date>
    </item>
  </channel>
</rss>

