<?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: Running count starting over when the counted value is not present previous date in Power Query</title>
    <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1711700#M52002</link>
    <description>&lt;P&gt;Thank you so much for the info, I didn't see that was the issue. Now everything seems to work perfectly and smoothly. It took just 1 or 2 sec tu run through all the data which means the speed is way more than good enough. It is also not complicated so that's awesome for someone who deesn't have much experience with M-code. Once again, thank you fo all your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Honzik&lt;/P&gt;</description>
    <pubDate>Tue, 09 Mar 2021 13:35:21 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-03-09T13:35:21Z</dc:date>
    <item>
      <title>Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1705349#M51851</link>
      <description>&lt;P&gt;Hi guys,&lt;BR /&gt;I'm new to PBI and Power Query and I can't find a solution to the following problem. To put it in context I have a dataset showing daily items on stock. The data is generated almost every working day but sometimes there are random time gaps when no data is generated at all. The simplified data looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Product ID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;6.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;6.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;6.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;9.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;9.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;9.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;11.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;11.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;14.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;14.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;14.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;15.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;15.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;15.1.2020&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;I managed to create a "running count" column using grouping and add index based on this tutorial (&lt;A href="https://www.youtube.com/watch?v=camNMc1zaBc&amp;amp;t=189s" target="_blank" rel="noopener"&gt;https://www.youtube.com/watch?v=camNMc1zaBc&amp;amp;t=189s&lt;/A&gt;) and I got the output shown in Table 1. As you can see, Product "C" was not present on 11/1/2020 but was present again on 14/1/2020 so the running count goes continuously on. The ouptut I need though, is the one shown in Table 2. I need the &lt;STRONG&gt;counting to start over anytime when product ID was not present the previous date and at least one product was.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you guys have any ideas? I will be sooo glad for any solution either if it's Power Query using raw data or DAX calculated column using the data with actual runnning count.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Honzik&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 05 Mar 2021 11:06:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1705349#M51851</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-05T11:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1706283#M51871</link>
      <description>&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;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTLTM9QzMjAyUIrViVZyQhdwRhcAabFE12KJrgVDhaEhuiGGJhhqTNCNQRUB6zLFUIMQiQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [prid = _t, date = _t]),
    #"Raggruppate righe1" = Table.Group(Origine, {"date"}, {{"all", each _[prid]}}),
    #"Rimosse altre colonne" = Table.SelectColumns(#"Raggruppate righe1",{"all"}),
    all = #"Rimosse altre colonne"[all],

    lg=List.Generate(
                ()=&amp;gt;[A=0,B=0,C=0,n=0],
                each [n]&amp;lt;=List.Count(all),
                each   [A=if List.Contains(all{[n]},"A")then [A]+1 else 0,
                        B=if List.Contains(all{[n]},"B")then [B]+1 else 0, 
                        C=if List.Contains(all{[n]},"C")then [C]+1 else 0,
                        n=[n]+1],
    each  Table.Transpose(Table.DemoteHeaders(Table.FromRecords({_[[A],[B],[C]]}))
    )),

   tc=Table.Combine(lg),
    #"Filtrate righe" = Table.SelectRows(tc, each ([Column2] &amp;lt;&amp;gt; 0))
in
    #"Filtrate righe"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="0"&gt;&lt;SPAN&gt;Try using a pattern like this.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="2"&gt;&lt;SPAN&gt;it's tangled (and for this reason I suggest you toi test carefully the script), but I can't find anything simpler and more direct for the moment.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 20:22:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1706283#M51871</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-05T20:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1706409#M51882</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you very much for an advice! Could you please add a little bit of information how to use the code, so the extra runing count column is created? Unfortunately I don't know how to use it properly so it doesn't work at the moment. I'm trying to find out the way myself using various tutorials but without success.&lt;/P&gt;&lt;P&gt;Also, the real dataset contains 10K+ of rows with hundreds of distinct product IDs which are all 14-digit numbers. On top of that, these IDs are added new every month so I need the solution to be flexible whenever there's a change. Do you think I'd be able to use your code if implemented correctly? I'm sorry I didn't mention that earlier but since I don't have much experience I supposed it was not that important but now I guess it probably is. Once again thanks a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Honzik&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 21:58:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1706409#M51882</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-05T21:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1706543#M51884</link>
      <description>&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="0"&gt;&lt;SPAN&gt;this adds the code to populate the table with the date column&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;
let
    Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTLTM9QzMjAyUIrViVZyQhdwRhcAabFE12KJrgVDhaEhuiGGJhhqTNCNQRUB6zLFUIMQiQUA", 
    BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type 
    table [prid = _t, date = _t]),
    
    d=Origine[date],
    #"Raggruppate righe1" = Table.Group(Origine, {"date"}, {{"all", each _[prid]}}),
    #"Rimosse altre colonne" = Table.SelectColumns(#"Raggruppate righe1",{"all"}),
    all = #"Rimosse altre colonne"[all],

    lg=List.Generate(
                ()=&amp;gt;[A=0,B=0,C=0,n=0],
                each [n]&amp;lt;=List.Count(all),
                each   [A=if List.Contains(all{[n]},"A")then [A]+1 else 0,
                        B=if List.Contains(all{[n]},"B")then [B]+1 else 0, 
                        C=if List.Contains(all{[n]},"C")then [C]+1 else 0,
                        n=[n]+1],
    each  Table.Transpose(Table.DemoteHeaders(Table.FromRecords({_[[A],[B],[C]]}))
    )),

   tc=Table.Combine(lg),
    #"Filtrate righe" = Table.SelectRows(tc, each ([Column2] &amp;lt;&amp;gt; 0)),
    ttc=Table.FromColumns({d}&amp;amp;Table.ToColumns(#"Filtrate righe"),{"date","grpid","idx"})
in
    ttc&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="0"&gt;&lt;SPAN&gt;as for the general problem, you should provide some more detailed examples (with fake data).&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="2"&gt;&lt;SPAN&gt;you should explain better in the more general cases the rule of formation of groups.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="4"&gt;&lt;SPAN&gt;do you confirm, for example, that the productid groups to be considered are identified as those associated with each date?&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="6"&gt;&lt;SPAN&gt;Finally, if you explained more generally what you start from and what you want to achieve, perhaps we could find a different way from that of having to index the products in this complicated way.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Mar 2021 05:48:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1706543#M51884</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-06T05:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1706565#M51889</link>
      <description>&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="0"&gt;&lt;SPAN&gt;try this using small tables initially and check run times.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="2"&gt;&lt;SPAN&gt;if it works for you with small tables and doesn't take too long, increase the size of the tables as you go.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTLTM9QzMjAyUIrViVZyQhdwRhcAabFE12KJrgVDhaEhuiGGJhhqTNCNQRVxwRABm2OKoQshEgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [prid = _t, date = _t]),
    
    d=Origine[date],
    all = Table.Group(Origine, {"date"}, {{"all", each _[prid]}})[all],
    allprid=List.Union(all),
    nprid=List.Count(allprid),
    rec0=Record.FromList(List.Repeat({0},nprid),allprid),
    lg=List.Generate(
                ()=&amp;gt;rec0&amp;amp;[n=0],
                each [n]&amp;lt;=List.Count(all),
                each   Record.TransformFields(_, List.Transform(allprid, (p)=&amp;gt; {p, (x)=&amp;gt;if List.Contains(all{[n]},p) then x+1 else 0}))&amp;amp;[n=[n]+1],
    each  Record.ToTable(Record.RemoveFields(_,"n"))
    ),

   tc=Table.Combine(lg),
    #"Filtrate righe" = Table.SelectRows(tc, each ([Value] &amp;lt;&amp;gt; 0)),
    ttc=Table.FromColumns({d}&amp;amp;Table.ToColumns(#"Filtrate righe"),{"date","grpid","idx"})
in
    ttc&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;</description>
      <pubDate>Sat, 06 Mar 2021 13:22:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1706565#M51889</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-06T13:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707009#M51901</link>
      <description>&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you very much for your help. I used the last script that you posted and it worked exactly as I need to. However, when I run it through larger dataset (15 K rows with around 1 K distinct Product IDs and 220 distinct dates) it took hours to process and unfortunately my laptop got frozen so I'll try again and leave it over night. In total, I need it to get through around 60 K rows. If it takes long but works out it's fine if I manage to set up refresh so it only goes through new data that would appear monthly (the data source is a folder where xls. files are put every month with more or less 1,5 K rows every time). Once again, thank you sooo much for your effort! I'd not be able to come up with anything close to this myself.&lt;/P&gt;&lt;P&gt;Honzik&lt;/P&gt;</description>
      <pubDate>Sat, 06 Mar 2021 23:33:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707009#M51901</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-06T23:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707163#M51908</link>
      <description>&lt;P&gt;try these versions, should perfom better (and the second better than first)&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;
&lt;LI-CODE lang="markup"&gt;let
    Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTLTM9QzMjAyUIrViVZyQhdwRhcAabFE12KJrgVDhaEhuiGGJhhqTNCNQRVxwRABm2OKoQshEgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [prid = _t, date = _t]),
    
    d=Origine[date],
    all = List.Buffer(Table.Group(Origine, {"date"}, {{"all", each _[prid]}})[all]),
    nall=List.Count(all),
    allprid=List.Buffer(List.Union(all)),
    nprid=List.Count(allprid),
    rec0=Record.FromList(List.Repeat({0},nprid),allprid),
    lg=List.Generate(
                ()=&amp;gt;rec0&amp;amp;[n=0],
                each [n]&amp;lt;=nall,
                each   Record.TransformFields(_, List.Transform(allprid, (p)=&amp;gt; {p, (x)=&amp;gt;if List.Contains(all{[n]},p) then x+1 else 0}))&amp;amp;[n=[n]+1],
    each  Record.ToTable(Record.RemoveFields(_,"n"))
    ),

   tc=Table.Combine(lg),
    #"Filtrate righe" = Table.SelectRows(tc, each ([Value] &amp;lt;&amp;gt; 0)),
    ttc=Table.FromColumns({d}&amp;amp;Table.ToColumns(#"Filtrate righe"),{"date","grpid","idx"})
in
    ttc&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;let
    Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTLTM9QzMjAyUIrViVZyQhdwRhcAabFE12KJrgVDhaEhuiGGJhhqTNCNQRVxwRABm2OKoQshEgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [prid = _t, date = _t]),
    
    d=Origine[date],
    all = List.Buffer(Table.Group(Origine, {"date"}, {{"all", each _[prid]}})[all]),
    nall=List.Count(all),
    allprid=List.Buffer(List.Union(all)),
    nprid=List.Count(allprid),
    rec0=Record.FromList(List.Repeat({0},nprid),allprid),
    lg=List.Generate(
                ()=&amp;gt;rec0&amp;amp;[n=0],
                each [n]&amp;lt;=nall,
                each   Record.TransformFields(_, List.Transform(allprid, (p)=&amp;gt; {p, (x)=&amp;gt;if List.Contains(all{[n]},p) then x+1 else 0}))&amp;amp;[n=[n]+1]
    ),
    lglb=List.Buffer(lg),
    tc=Table.Combine(List.Transform(lglb, each Record.ToTable(_))),
    #"Filtrate righe" = Table.SelectRows(tc, each ([Value] &amp;lt;&amp;gt; 0 and [Name]&amp;lt;&amp;gt;"n")),
    ttc=Table.FromColumns({d}&amp;amp;Table.ToColumns(#"Filtrate righe"),{"date","grpid","idx"})
in
    ttc&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="0"&gt;&lt;SPAN&gt;PS&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="0"&gt;&lt;SPAN&gt;I came up with a different idea on how to do it, but I need time to implement it.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="2"&gt;&lt;SPAN&gt;In this case without using the list.generate function which works one record at a time and therefore could be much faster.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="2"&gt;&lt;SPAN&gt;PPS&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="2"&gt;&lt;SPAN&gt;If you can upload a table with your productIDs and dates, I can do some tests. I don't think publishing productIDs and a list of dates is a problem (since they are just numeric codes), is it? eventually you can also "encode" them and dates by removing or adding something to all. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 07:52:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707163#M51908</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-07T07:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707344#M51911</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is the link where I uploaded the dataset - &lt;A href="https://drive.google.com/file/d/16ooEjU8S-T2dPVic9cf3QvntIpUGl41a/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/16ooEjU8S-T2dPVic9cf3QvntIpUGl41a/view?usp=sharing&lt;/A&gt; There's one more column showing Warehouse ID I was asked to add but there's no need to calculate with that value - it's just supposed to be displayed in the final table. I'm slowly starting to understand how some of the M code works but still struggling to do this ony my own.&lt;BR /&gt;I have not tried the last script you posted but the one before worked though it took hours for my laptop to process more data. Once again big thanks for everything, you've already helped a lot.&lt;/P&gt;&lt;P&gt;Honzik&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 12:43:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707344#M51911</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-07T12:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707426#M51913</link>
      <description>&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="0"&gt;&lt;SPAN&gt;I ran the last script on the first 25k records of your file.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="2"&gt;&lt;SPAN&gt;in my laptop it took about 6 '.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 15:05:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707426#M51913</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-07T15:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707458#M51914</link>
      <description>&lt;P&gt;You're genius!&lt;/P&gt;&lt;P&gt;And hopefully the last thing - how do I add back the warehouse column please? The way I meant it was that it has to remain in the final table. I suppose there's no need for any big change in your script but I'm unable to figure out how to run it with original 3-column table (ProductID, Date, Warehouse). The ProductID-Date-Warehouse combination is supposed to be the same as in the raw table. Is there any easy way how to modify it so it remains there? Sorry that I did't explain in clearly in the last reply. I already feel bad for not being able to make that change on my own and bothering you with all that but my guess is it should not be anything too hardt though my skills are currently insufficient.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Honzik&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 17:35:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707458#M51914</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-07T17:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707477#M51916</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp; and&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;BR /&gt;you might be interested in an approach that runs the full dataset in seconds instead of minutes:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
fnIdx = 
(myTable as table) =&amp;gt;
let
partition = Table.Buffer(myTable),
dates = AllDatesWthIndex,
    #"Merged Queries" = Table.NestedJoin(partition, {"Date"}, dates, {"Date"}, "Changed Type", JoinKind.LeftOuter),
    #"Expanded Changed Type" = Table.ExpandTableColumn(#"Merged Queries", "Changed Type", {"Index"}, {"Index"}),
    Custom1 = Table.ToColumns(#"Expanded Changed Type"),
    IndexedTable = Table.Buffer( Table.FromColumns(Custom1 &amp;amp; { {null} &amp;amp; List.RemoveLastN(List.Last(Custom1),1) }, {"ID", "Date", "Index", "PrevIndex"}) ),
    Initial = IndexedTable{0} &amp;amp; [Counter = 0, Idx = 1],
    Custom3 = List.Generate( ()=&amp;gt; Initial,
        each [Counter] &amp;lt; Table.RowCount(IndexedTable),
        each [ Counter = [Counter] + 1,
               Idx = if IndexedTable[Index]{Counter} - IndexedTable[PrevIndex]{Counter} = 1 then [Idx] + 1 else 1
               ]),
    #"Converted to Table" = Table.FromList(Custom3, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Idx"}, {"Idx"})[Idx],
    Custom2 = Table.FromColumns( Table.ToColumns( IndexedTable ) &amp;amp; { #"Expanded Column1" })
in
    Custom2,

    Origine = dataSample,
    Selection = Table.FirstN(Origine,CountRecordsImke),
    AllDates=Table.Buffer( Table.Distinct(Table.SelectColumns(Selection, {"Date"})) ),
    AllDatesWthIndex = Table.AddIndexColumn(AllDates, "Index", 0, 1, Int64.Type),
    AllProducts = Origine,
    #"Grouped Rows" = Table.Group(Selection, {"ProductID"}, {{"ProductPartition", each _}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each fnIdx([ProductPartition])),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Column2", "Column5"}, {"Date", "Index"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"ProductPartition"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"Date", type date}, {"Index", Int64.Type}, {"ProductID", type text}})
in
    #"Changed Type"&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;It runs the logic on the level of the individual ProductIDs like I've described here:&amp;nbsp;&lt;A href="https://www.thebiccountant.com/2017/05/29/performance-tip-partition-tables-crossjoins-possible-powerquery-powerbi/" target="_blank"&gt;Performance Tip: Partition your tables at crossjoins where possible - PowerQuery PowerBI – The BIccountant&lt;/A&gt;&lt;BR /&gt;and uses a shifted index method which also makes comparisons very fast:&amp;nbsp;&amp;nbsp;&lt;A href="https://www.thebiccountant.com/2018/07/12/fast-and-easy-way-to-reference-previous-or-next-rows-in-power-query-or-power-bi/" target="_blank"&gt;Fast and easy way to reference previous or next rows in Power Query or Power BI – The BIccountant&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Power Query doesn't have to be slow if you do it the right way. I've collected some tipps and tricks to improve performance here:&amp;nbsp;&lt;A href="https://www.thebiccountant.com/speedperformance-aspects/" target="_blank"&gt;Speed/Performance aspects – The BIccountant&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 18:57:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707477#M51916</guid>
      <dc:creator>ImkeF</dc:creator>
      <dc:date>2021-03-07T18:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707519#M51923</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1522" data-lia-user-login="ImkeF" class="lia-mention lia-mention-user"&gt;ImkeF&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you very much for your solution. I'll go through it so I can better undestand the concept but looks like great approach to it! One more question - could you please give me a hint how to run it using all columns (including Warehouse) so the warehouse values remain there when it's finished? (Dateset including that column is here &lt;A href="https://drive.google.com/file/d/16ooEjU8S-T2dPVic9cf3QvntIpUGl41a/view?usp=sharing" target="_blank" rel="nofollow noopener noreferrer"&gt;https://drive.google.com/file/d/16ooEjU8S-T2dPVic9cf3QvntIpUGl41a/view?usp=sharing.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Honzik&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 21:01:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707519#M51923</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-07T21:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707521#M51925</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;you have to modify the code like so:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
fnIdx = 
(myTable as table) =&amp;gt;
let
partition = Table.Buffer(myTable),
dates = AllDatesWthIndex,
    #"Merged Queries" = Table.NestedJoin(partition, {"Date"}, dates, {"Date"}, "Changed Type", JoinKind.LeftOuter),
    #"Expanded Changed Type" = Table.ExpandTableColumn(#"Merged Queries", "Changed Type", {"Index"}, {"Index"}),
    Custom1 = Table.ToColumns(#"Expanded Changed Type"),
    IndexedTable = Table.Buffer( Table.Sort(Table.FromColumns(Custom1 &amp;amp; { {null} &amp;amp; List.RemoveLastN(List.Last(Custom1),1) }, {"ID", "Date", "Warehouse", "Index", "PrevIndex"}), "Index") ),
    Initial = IndexedTable{0} &amp;amp; [Counter = 0, Idx = 1],
    Custom3 = List.Generate( ()=&amp;gt; Initial,
        each [Counter] &amp;lt; Table.RowCount(IndexedTable),
        each [ Counter = [Counter] + 1,
               Idx = if IndexedTable[Index]{Counter} - IndexedTable[PrevIndex]{Counter} = 1 then [Idx] + 1 else 1
               ]),
    #"Converted to Table" = Table.FromList(Custom3, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Idx"}, {"Idx"})[Idx],
    Custom2 = Table.FromColumns( Table.ToColumns( IndexedTable ) &amp;amp; { #"Expanded Column1" })
in
    Custom2,

    Origine = dataSample,
    Selection = Table.FirstN(Origine,CountRecordsImke),
    AllDates=Table.Buffer( Table.Distinct(Table.SelectColumns(Selection, {"Date"})) ),
    AllDatesWthIndex = Table.AddIndexColumn(AllDates, "Index", 0, 1, Int64.Type),
    AllProducts = Origine,
    #"Grouped Rows" = Table.Group(Selection, {"ProductID"}, {{"ProductPartition", each _}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each fnIdx([ProductPartition])),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Column2", "Column3", "Column6"}, {"Date", "Warehouse", "Index"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"ProductPartition"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"Date", type date}, {"Index", Int64.Type}, {"ProductID", type text}})
in
    #"Changed Type"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please also see the file attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 21:32:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1707521#M51925</guid>
      <dc:creator>ImkeF</dc:creator>
      <dc:date>2021-03-07T21:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1708277#M51938</link>
      <description>&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="0"&gt;&lt;SPAN&gt;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="0"&gt;&lt;SPAN&gt;exaggerated.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="1"&gt;&lt;SPAN&gt;Try this one should be even faster than my last one.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="3"&gt;&lt;SPAN&gt;I don't know if faster than &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1522" data-lia-user-login="ImkeF" class="lia-mention lia-mention-user"&gt;ImkeF&lt;/a&gt; 's, but this doesn't use List.generate, and you caùn execute all the steps (except the one who does the grouping)&amp;nbsp; with the UI&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="3"&gt;&lt;SPAN&gt;You have also the extra column [Warehouse]&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTLTM9QzMjAyUIrViVZyQhdwRhcAabFE12KJrgVFwAWbFkNDdFMNTTDUmKCbiyoC1mWKocYU3XIkkVgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [prid = _t, date = _t]),
    #"Modificato tipo" = Table.TransformColumnTypes(Origine,{{"date", type date}}),
    #"Raggruppate righe" = Table.Group(#"Modificato tipo", {"date"}, {{"all", each _, type table [prid=nullable text, date=nullable text]}}),
    #"Aggiunta colonna indice" = Table.AddIndexColumn(#"Raggruppate righe", "Indice", 1, 1, Int64.Type),
    #"Tabella all espansa" = Table.ExpandTableColumn(#"Aggiunta colonna indice", "all", {"prid"}, {"prid"}),
    #"Ordinate righe" = Table.Sort(#"Tabella all espansa",{{"prid", Order.Ascending}, {"Indice", Order.Ascending}}),
    #"Aggiunta colonna indice1" = Table.AddIndexColumn(#"Ordinate righe", "dist", 0, 1, Int64.Type),
    #"Raggruppate righe1" = Table.Group(#"Aggiunta colonna indice1", "prid", {"ccc",each Table.Group(_, {"Indice","dist"}, {{"all", (c)=&amp;gt; Table.AddIndexColumn(c,"counter",1,1)}},GroupKind.Local,(x,y)=&amp;gt;Number.From(y[Indice]-x[Indice]&amp;gt;y[dist]))}),
    #"Tabella ccc espansa1" = Table.ExpandTableColumn(#"Raggruppate righe1", "ccc", {"Indice", "dist", "all"}, {"Indice", "dist", "all"}),
    #"Tabella all espansa1" = Table.ExpandTableColumn(#"Tabella ccc espansa1", "all", {"date", "counter"}, {"date", "counter"}),
    #"Ordinate righe1" = Table.Sort(#"Tabella all espansa1",{{"date", Order.Ascending}}),
    #"Rimosse colonne" = Table.RemoveColumns(#"Ordinate righe1",{"Indice", "dist"}),
    #"Riordinate colonne" = Table.ReorderColumns(#"Rimosse colonne",{"date", "prid", "counter"})
in
    #"Riordinate colonne"&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 12:57:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1708277#M51938</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-08T12:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1709445#M51955</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for that. I tested it on my own but for some reason the last script (meaning the one in "ABCricomincia3b.pbix" file and teble including Warehouse column). I randomly picked ProductID and usualy the result was this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I might have done something wrong but the snapshot was taken from the file unchanged (mentioned above). Idk what exactly caused that but for thos moment I'll use the solution by &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1522" data-lia-user-login="ImkeF" class="lia-mention lia-mention-user"&gt;ImkeF&lt;/a&gt;. Thank you for all the help you provided, I appreciate it a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Honzik&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 16:09:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1709445#M51955</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-08T16:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1709452#M51956</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1522" data-lia-user-login="ImkeF" class="lia-mention lia-mention-user"&gt;ImkeF&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the script and it runs great and quick. As I'm a beginner to M-code, I'll have to work on understanding it but it serves me very well. Thank you so much for your effort.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Honzik&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 16:11:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1709452#M51956</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-08T16:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1709646#M51958</link>
      <description>&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="0"&gt;&lt;SPAN&gt;The problem seems to be due to this expression, which should be equivalent to the second, but for some strange reason it doesn't work.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="2"&gt;&lt;SPAN&gt;Try now.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="4"&gt;&lt;SPAN&gt;I'm curious to know if you can measure the execution speed.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;= Table.Sort(#"Tabella all espansa",{{"ProductID", Order.Ascending}, {"Indice", Order.Ascending}})&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;= Table.Sort(#"Tabella all espansa",{{"ProductID", Order.Ascending}, {"Date", Order.Ascending}})&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 17:28:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1709646#M51958</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-08T17:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1711221#M51992</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for the update. The previous issue was solved and it runs very fast. I ran it through small sample of data to test it if it starts counting over when ProductID value is missing the previous present Date and unfortunately it did not work out as expected (see below).&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;This is the sample a ran it through, just 17 rows (&lt;A href="https://drive.google.com/file/d/1ctZSZHt8R8M37I5aaQmAii5leVQrMOW0/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/1ctZSZHt8R8M37I5aaQmAii5leVQrMOW0/view?usp=sharing&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Honzik&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 10:10:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1711221#M51992</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-09T10:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1711397#M51994</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/a&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="0"&gt;&lt;SPAN&gt;First of all, I congratulate you for being an excellent tester.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="2"&gt;&lt;SPAN&gt;But then I tell you that I do not agree on the expected result that you indicate on the demo_real file.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="4"&gt;&lt;SPAN&gt;I am attaching a screen with the result that, from your previous descriptions, I would expect.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="6"&gt;&lt;SPAN&gt;I have corrected the script and am always curious to know how long it takes to work your complete file.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="auto" data-phrase-index="8"&gt;&lt;SPAN&gt;The script assumes that the data are sorted by date, otherwise you have to add a statement to that effect at the beginning.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 11:19:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1711397#M51994</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-09T11:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Running count starting over when the counted value is not present previous date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1711700#M52002</link>
      <description>&lt;P&gt;Thank you so much for the info, I didn't see that was the issue. Now everything seems to work perfectly and smoothly. It took just 1 or 2 sec tu run through all the data which means the speed is way more than good enough. It is also not complicated so that's awesome for someone who deesn't have much experience with M-code. Once again, thank you fo all your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Honzik&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 13:35:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Running-count-starting-over-when-the-counted-value-is-not/m-p/1711700#M52002</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-09T13:35:21Z</dc:date>
    </item>
  </channel>
</rss>

