<?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: Detect Past Month lost customer in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3481920#M133140</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="631873" data-lia-user-login="APR92" class="lia-mention lia-mention-user"&gt;APR92&lt;/a&gt;, there is probably a much cleaner way to do this, but try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Lost2 = 
VAR selectedDate =
    SELECTEDVALUE(Consulta1[Date])
VAR selectedCategory =
    SELECTEDVALUE(Consulta1[Category])
VAR tbl =
    ADDCOLUMNS (
        ADDCOLUMNS (
            Consulta1,
            "Active Last Month",
                MAXX (
                    FILTER (
                        ALL ( Consulta1 ),
                        Consulta1[Date] &amp;lt; EARLIER(Consulta1[Date])
                            &amp;amp;&amp;amp; (
                                Consulta1[Category] = EARLIER(Consulta1[Category])
                                    || ISBLANK ( EARLIER(Consulta1[Category]) )
                            )
                    ),
                    Consulta1[Active]
                )
        ),
        "Lost",
            SWITCH (
                TRUE,
                ISBLANK ( [Active Last Month] ), BLANK (),
                [Active Last Month] &amp;lt; Consulta1[Active], 0,
                [Active Last Month] - Consulta1[Active]
            )
    )
VAR lost = 
    SUMX (
        FILTER (
            tbl,
            Consulta1[Date] = selectedDate
                &amp;amp;&amp;amp; (
                    Consulta1[Category] = selectedCategory
                        || ISBLANK ( selectedCategory )
                )
        ),
        [Lost]
    )
RETURN lost&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;</description>
    <pubDate>Tue, 17 Oct 2023 20:44:17 GMT</pubDate>
    <dc:creator>giammariam</dc:creator>
    <dc:date>2023-10-17T20:44:17Z</dc:date>
    <item>
      <title>Detect Past Month lost customer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3479774#M132998</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to find the customers that I lost from the previous month.&lt;/P&gt;&lt;P&gt;So far I've been able to calculate it individually &lt;STRONG&gt;but I'm stuck with the subtotals&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The model is a single table inndicating if a customer is active or not. The expected outcome is the measure "Lost".&lt;/P&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;The measure for past months looks like this (works fine):&lt;/P&gt;&lt;DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;Past Month =:&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;VAR var1 = &lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; CALCULATE(&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SUM(Consulta1[Active]),&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PREVIOUSMONTH(Consulta1[Date])&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; )&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;RETURN&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; var1&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;The measure for lost looks like this (the subtotals don't work fine):&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV class="lia-indent-padding-left-90px"&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;Lost =&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;var1&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Consulta1&lt;/SPAN&gt;&lt;SPAN&gt;[Active]&lt;/SPAN&gt;&lt;SPAN&gt;) - &lt;/SPAN&gt;&lt;SPAN&gt;[Past Month]&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var1&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;=&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;BLANK&lt;/SPAN&gt;&lt;SPAN&gt;(),&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var1&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-90px"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Any idea? Thanks!!&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 17 Oct 2023 06:32:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3479774#M132998</guid>
      <dc:creator>APR92</dc:creator>
      <dc:date>2023-10-17T06:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Past Month lost customer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3479864#M133001</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="631873" data-lia-user-login="APR92" class="lia-mention lia-mention-user"&gt;APR92&lt;/a&gt;&amp;nbsp;try this. The negatives under the Lost field made it a bit confusing. I made some assumptions with the business rules:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If the prior date was the first date in the dataset, then [Lost] and [Past Month] are BLANK()&lt;/LI&gt;&lt;LI&gt;If Sum of Active is &amp;gt; [Past Month] then [Lost] = 0&lt;/LI&gt;&lt;LI&gt;If Sum of Active is &amp;lt;= [Past Month] then [Lost] = [Past Month] - [Active]&lt;UL&gt;&lt;LI&gt;Note, if you want negatives in the [Lost] column, then you can switch this to [Active]-[Past Month]&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;The Subtotals for [Lost] follow the above rules as well&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Let me know if any of these rules are incorrect.&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;LI-CODE lang="markup"&gt;Past Month = 
VAR var1 =
    CALCULATE(
        SUM(Consulta1[Active]),
        PREVIOUSMONTH(Consulta1[Date])
    )

VAR maxDate = MAXX(
    ALLSELECTED(Consulta1),
    Consulta1[Date]
)

VAR sumMinusMaxDate = SUMX(
    FILTER(
        ALLSELECTED(Consulta1),
        Consulta1[Date] &amp;lt;&amp;gt; maxDate
    ),
Consulta1[Active]
)

RETURN
    IF(
        COUNTROWS(ALLSELECTED(Consulta1)) = COUNTROWS(Consulta1),
         sumMinusMaxDate,
         var1
    )&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;LI-CODE lang="markup"&gt;Lost = 
    VAR sumActive = SUM(Consulta1[Active])
    VAR var1 = SWITCH(
        TRUE,
        ISBLANK([Past Month]), BLANK(),
        sumActive&amp;lt;=[Past Month], [Past Month]-sumActive,
        sumActive&amp;gt;[Past Month], 0
        
    )

    RETURN
    var1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this is enough to get you going please consider liking this reply and choosing it as the solution. Otherwise, I'm happy to help further.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 23:42:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3479864#M133001</guid>
      <dc:creator>giammariam</dc:creator>
      <dc:date>2023-10-16T23:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Past Month lost customer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3480351#M133030</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="124852" data-lia-user-login="giammariam" class="lia-mention lia-mention-user"&gt;giammariam&lt;/a&gt;&amp;nbsp;Hello, the subtotal for the period 2023-03 is not correct. The user granularity results is fine.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Thank you a lot for your time!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 15:00:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3480351#M133030</guid>
      <dc:creator>APR92</dc:creator>
      <dc:date>2023-10-17T15:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Past Month lost customer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3481487#M133116</link>
      <description>&lt;P&gt;I'm super stuck with it. Help please :$&lt;/P&gt;&lt;P&gt;I've played a little bit the past period measure, but the subtotals still wrong...&lt;/P&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="124852" data-lia-user-login="giammariam" class="lia-mention lia-mention-user"&gt;giammariam&lt;/a&gt;&amp;nbsp;'s response has the exact same issue with the lost's subtotals.&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;Users Lost Past Period =&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;VAR var1=&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; CALCULATETABLE ( &lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; VALUES ( CALC_userreport_Summarized[user_name] ), &lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ALL(),&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PREVIOUSMONTH(CALC_userreport_Summarized[Date]),&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CALC_userreport_Summarized[user_name] = SELECTEDVALUE(CALC_userreport_Summarized[user_name])&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; )&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;VAR var2 = COUNTROWS(var1)&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;VAR var3 = &lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; IF(&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var2 - [Users Past Period] = 0,&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BLANK(),&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var2 - [Users Past Period]&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; )&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;RETURN&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#008000"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; var3&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 17 Oct 2023 15:44:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3481487#M133116</guid>
      <dc:creator>APR92</dc:creator>
      <dc:date>2023-10-17T15:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Past Month lost customer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3481563#M133126</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="631873" data-lia-user-login="APR92" class="lia-mention lia-mention-user"&gt;APR92&lt;/a&gt;,&amp;nbsp;this is because of the desired behavior was unclear. Overall for 2023-03 you had 4 currently active where you only had 3 active the month before. Since you still ended up with a total of more active than you did the previous month, the [Lost] metric is indicating that overall you didn't lose any for that month. Sounds like instead you want a total of any lost, regardless of what the overall picture is for that month. Now that I know that this is the desired behavior I'll try to get this implemented as soon as I get a chance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 16:17:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3481563#M133126</guid>
      <dc:creator>giammariam</dc:creator>
      <dc:date>2023-10-17T16:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Past Month lost customer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3481579#M133127</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="124852" data-lia-user-login="giammariam" class="lia-mention lia-mention-user"&gt;giammariam&lt;/a&gt;&amp;nbsp;Hello,&lt;/P&gt;&lt;P&gt;First of all apologizes if the logic is not clear. Let me clarify:&lt;/P&gt;&lt;P&gt;I would like to determine how many customers I've lost this month versus the ones that I had the previous month only.&lt;/P&gt;&lt;P&gt;This means that any previous customer I had older than the previous month does't count. The comparison is month by month.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For example, I have to compare the customers that were active in february with the customers that were active in january.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The expected result right now is fine with the user granularity&lt;STRONG&gt; but the montly subtotals are not showing a proper value:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;As you can see the subtotal "2023-02" is correct as is adding up user B and E that are lost.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The subtotal 2023-03 is wrong as is 0 and is not adding up the user C that is los (highlighted in green).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PS: Don't worry about the grand total as it is not needed in this measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much, I highly appreciate your support! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 16:29:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3481579#M133127</guid>
      <dc:creator>APR92</dc:creator>
      <dc:date>2023-10-17T16:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Past Month lost customer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3481920#M133140</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="631873" data-lia-user-login="APR92" class="lia-mention lia-mention-user"&gt;APR92&lt;/a&gt;, there is probably a much cleaner way to do this, but try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Lost2 = 
VAR selectedDate =
    SELECTEDVALUE(Consulta1[Date])
VAR selectedCategory =
    SELECTEDVALUE(Consulta1[Category])
VAR tbl =
    ADDCOLUMNS (
        ADDCOLUMNS (
            Consulta1,
            "Active Last Month",
                MAXX (
                    FILTER (
                        ALL ( Consulta1 ),
                        Consulta1[Date] &amp;lt; EARLIER(Consulta1[Date])
                            &amp;amp;&amp;amp; (
                                Consulta1[Category] = EARLIER(Consulta1[Category])
                                    || ISBLANK ( EARLIER(Consulta1[Category]) )
                            )
                    ),
                    Consulta1[Active]
                )
        ),
        "Lost",
            SWITCH (
                TRUE,
                ISBLANK ( [Active Last Month] ), BLANK (),
                [Active Last Month] &amp;lt; Consulta1[Active], 0,
                [Active Last Month] - Consulta1[Active]
            )
    )
VAR lost = 
    SUMX (
        FILTER (
            tbl,
            Consulta1[Date] = selectedDate
                &amp;amp;&amp;amp; (
                    Consulta1[Category] = selectedCategory
                        || ISBLANK ( selectedCategory )
                )
        ),
        [Lost]
    )
RETURN lost&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;</description>
      <pubDate>Tue, 17 Oct 2023 20:44:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Detect-Past-Month-lost-customer/m-p/3481920#M133140</guid>
      <dc:creator>giammariam</dc:creator>
      <dc:date>2023-10-17T20:44:17Z</dc:date>
    </item>
  </channel>
</rss>

