<?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 Consecutive Count by CustomerId, SubscriptionId &amp;amp; Status in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Consecutive-Count-by-CustomerId-SubscriptionId-amp-Status/m-p/2384105#M61726</link>
    <description>&lt;P&gt;Hi PBI Community!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table of data similar to the below - and am looking to get a count of consecutive closed-lost opportunities by CustomerId and SubscriptionId.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've seen a couple of consecutive count tutorials, but none that also factor in an additional layer of 'by customer' and 'by subscription' as well since a customer can have more than one subscription at a given time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, once a customer has four consecutive months of a closed-lost subscription, their overall subscription moves to cancelled -- so, I'm trying to flag those that might be on the cusp of an overall cancellation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;CustomerId&lt;/TD&gt;&lt;TD&gt;SubscriptionId&lt;/TD&gt;&lt;TD&gt;CloseDate&lt;/TD&gt;&lt;TD&gt;Amount&lt;/TD&gt;&lt;TD&gt;Stage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CustomerA&lt;/TD&gt;&lt;TD&gt;1A&lt;/TD&gt;&lt;TD&gt;3/1/2021&lt;/TD&gt;&lt;TD&gt;$10&lt;/TD&gt;&lt;TD&gt;Closed-Lost&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CustomerA&lt;/TD&gt;&lt;TD&gt;1A&lt;/TD&gt;&lt;TD&gt;2/1/2021&lt;/TD&gt;&lt;TD&gt;$10&lt;/TD&gt;&lt;TD&gt;Closed-Lost&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CustomerB&lt;/TD&gt;&lt;TD&gt;2A&lt;/TD&gt;&lt;TD&gt;1/1/2021&lt;/TD&gt;&lt;TD&gt;$5&lt;/TD&gt;&lt;TD&gt;Closed-Won&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CustomerA&lt;/TD&gt;&lt;TD&gt;1A&lt;/TD&gt;&lt;TD&gt;1/1/2021&lt;/TD&gt;&lt;TD&gt;$5&lt;/TD&gt;&lt;TD&gt;Closed-Won&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As of 1/1, Cust A has 0 Closed-Lost opps, but as of 3/1, Cust A now has 2 consecutive closed-lost opps. Unsure if a conditional column or measure makes more sense here, but any ideas are greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 09 Mar 2022 18:06:21 GMT</pubDate>
    <dc:creator>samdep</dc:creator>
    <dc:date>2022-03-09T18:06:21Z</dc:date>
    <item>
      <title>Consecutive Count by CustomerId, SubscriptionId &amp; Status</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Consecutive-Count-by-CustomerId-SubscriptionId-amp-Status/m-p/2384105#M61726</link>
      <description>&lt;P&gt;Hi PBI Community!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table of data similar to the below - and am looking to get a count of consecutive closed-lost opportunities by CustomerId and SubscriptionId.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've seen a couple of consecutive count tutorials, but none that also factor in an additional layer of 'by customer' and 'by subscription' as well since a customer can have more than one subscription at a given time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, once a customer has four consecutive months of a closed-lost subscription, their overall subscription moves to cancelled -- so, I'm trying to flag those that might be on the cusp of an overall cancellation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;CustomerId&lt;/TD&gt;&lt;TD&gt;SubscriptionId&lt;/TD&gt;&lt;TD&gt;CloseDate&lt;/TD&gt;&lt;TD&gt;Amount&lt;/TD&gt;&lt;TD&gt;Stage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CustomerA&lt;/TD&gt;&lt;TD&gt;1A&lt;/TD&gt;&lt;TD&gt;3/1/2021&lt;/TD&gt;&lt;TD&gt;$10&lt;/TD&gt;&lt;TD&gt;Closed-Lost&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CustomerA&lt;/TD&gt;&lt;TD&gt;1A&lt;/TD&gt;&lt;TD&gt;2/1/2021&lt;/TD&gt;&lt;TD&gt;$10&lt;/TD&gt;&lt;TD&gt;Closed-Lost&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CustomerB&lt;/TD&gt;&lt;TD&gt;2A&lt;/TD&gt;&lt;TD&gt;1/1/2021&lt;/TD&gt;&lt;TD&gt;$5&lt;/TD&gt;&lt;TD&gt;Closed-Won&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CustomerA&lt;/TD&gt;&lt;TD&gt;1A&lt;/TD&gt;&lt;TD&gt;1/1/2021&lt;/TD&gt;&lt;TD&gt;$5&lt;/TD&gt;&lt;TD&gt;Closed-Won&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As of 1/1, Cust A has 0 Closed-Lost opps, but as of 3/1, Cust A now has 2 consecutive closed-lost opps. Unsure if a conditional column or measure makes more sense here, but any ideas are greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 18:06:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Consecutive-Count-by-CustomerId-SubscriptionId-amp-Status/m-p/2384105#M61726</guid>
      <dc:creator>samdep</dc:creator>
      <dc:date>2022-03-09T18:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Consecutive Count by CustomerId, SubscriptionId &amp; Status</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Consecutive-Count-by-CustomerId-SubscriptionId-amp-Status/m-p/2390082#M62119</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="294395" data-lia-user-login="samdep" class="lia-mention lia-mention-user"&gt;samdep&lt;/a&gt;&amp;nbsp;can you share some raw data to work with?&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 19:43:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Consecutive-Count-by-CustomerId-SubscriptionId-amp-Status/m-p/2390082#M62119</guid>
      <dc:creator>littlemojopuppy</dc:creator>
      <dc:date>2022-03-12T19:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Consecutive Count by CustomerId, SubscriptionId &amp; Status</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Consecutive-Count-by-CustomerId-SubscriptionId-amp-Status/m-p/2390184#M62125</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="17198" data-lia-user-login="littlemojopuppy" class="lia-mention lia-mention-user"&gt;littlemojopuppy&lt;/a&gt;&amp;nbsp;- thanks for your response! I don't think I have the ability to attach a pbix file, but I sent it to myself as a wetransfer link&amp;nbsp;&lt;A href="https://wetransfer.com/downloads/57c7819c26fae486a3639749e843940020220312215902/ea00416c805bf49cb9c7ab896dcc80d420220312215942/656134" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;https://wetransfer.com/downloads/57c7819c26fae486a3639749e843940020220312215902/ea00416c805bf49cb9c7ab896dcc80d420220312215942/656134&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hopefully, you can access this sample data. I was thinking that if I could create a conditional column or measure that places the count of consecutive closed-lost opportunities on the max date record by donor, that would solve for my need - ie: doesn't need to be a running count on every record, just the latest or max date by donor. Thanks again for looking into this!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 22:05:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Consecutive-Count-by-CustomerId-SubscriptionId-amp-Status/m-p/2390184#M62125</guid>
      <dc:creator>samdep</dc:creator>
      <dc:date>2022-03-12T22:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: Consecutive Count by CustomerId, SubscriptionId &amp; Status</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Consecutive-Count-by-CustomerId-SubscriptionId-amp-Status/m-p/2400262#M62781</link>
      <description>&lt;P&gt;&lt;FONT&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="294395" data-lia-user-login="samdep" class="lia-mention lia-mention-user"&gt;samdep&lt;/a&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a solution for this scenario,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(1) Create a column in Power Query,&lt;/P&gt;
&lt;P&gt;M code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyVtJRcgRi55z84tQUBZ/84hIgT8XIAEga6xvpGxkYGQGZJkqxOtFK5haW2JWbQpQbwpQbKoDV4zfeCGE8EaoNSVMNNdwQp/Lw/DyEakOSVBuQotoSTbGJqRmQ6YTpbkNoGMK9aUyEeiMk9UQoNySoHOp0Q2ggIiuPBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DonorId = _t, SubscriptionId = _t, StageName = _t, OpportunityAmount = _t, CloseDate = _t, #"Goal Column or Measure" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DonorId", type text}, {"SubscriptionId", type text}, {"StageName", type text}, {"OpportunityAmount", Currency.Type}, {"CloseDate", type date}, {"Goal Column or Measure", type text}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type",{{"CloseDate", Order.Ascending}}),
    #"Add Column"= Table.AddColumn(#"Sorted Rows", "Count",  (r) =&amp;gt; if r[StageName] = "Closed Lost"
           then List.Count(
                    List.LastN(
                        Table.SelectRows(
                            #"Sorted Rows",
                            each [DonorId] = r[DonorId] and [SubscriptionId]=r[SubscriptionId] and [CloseDate] &amp;lt;= r[CloseDate]
                        )[StageName],
                        each _ = "Closed Lost"
                    )
                )
           else 0)
in
    #"Add Column"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then it returns a column&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;(2) then create a calculated column with DAX code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column = 
var _closedate= CALCULATE(MAX('test'[CloseDate]),FILTER('test','test'[DonorId]=EARLIER('test'[DonorId]) &amp;amp;&amp;amp; test[SubscriptionId]=EARLIER( test[SubscriptionId]) &amp;amp;&amp;amp; test[Count]&amp;gt;0))
return IF(test[CloseDate]= _closedate,test[Count],BLANK())&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 style="background: white; margin: 7.5pt 0in .0001pt 0in;"&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background: white; box-sizing: border-box; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px; margin: 7.5pt 0in .0001pt 0in;"&gt;&lt;SPAN&gt;Community Support Team _Tang&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background: white; box-sizing: border-box; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px; margin: 7.5pt 0in .0001pt 0in;"&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG style="box-sizing: border-box;"&gt;helps&lt;/STRONG&gt;, please consider&amp;nbsp;&lt;STRONG style="box-sizing: border-box;"&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 10:08:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Consecutive-Count-by-CustomerId-SubscriptionId-amp-Status/m-p/2400262#M62781</guid>
      <dc:creator>v-xiaotang</dc:creator>
      <dc:date>2022-03-17T10:08:48Z</dc:date>
    </item>
  </channel>
</rss>

