<?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: calculate  running total of consecutive value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/1050246#M14339</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this, I'm hoping someone will come up with a more efficient version, but for now, at least you have some solution.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column = 
VAR __date = 'Table'[Date]
VAR __allResource = ALLEXCEPT( 'Table', 'Table'[Resource] ) 
VAR __firstZero =  
    CALCULATE(
        MAX( 'Table'[Date] ),
        __allResource,
        'Table'[Date] &amp;lt;= __date,
        'Table'[Billable] = 0
    )
VAR __start = 
    IF( 
        ISBLANK( __firstZero ),  
        CALCULATE(
            MIN( 'Table'[Date] ),
            __allResource
        ),
        __firstZero
    )
RETURN 
CALCULATE(
    SUM( 'Table'[Billable] ),
    FILTER(
        ALL( 'Table'[Date] ),
        'Table'[Date] &amp;gt;= __start &amp;amp;&amp;amp; 'Table'[Date] &amp;lt;= __date 
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;See the attached for ref as well&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;Best Regards,&lt;BR /&gt;Mariusz&lt;BR /&gt;&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accepting it as the solution&lt;/I&gt;&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;Please feel free to connect with me.&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/mariusz-repczynski-065a7362/" target="_blank"&gt; LinkedIn &lt;/A&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Apr 2020 08:44:52 GMT</pubDate>
    <dc:creator>Mariusz</dc:creator>
    <dc:date>2020-04-27T08:44:52Z</dc:date>
    <item>
      <title>calculate  running total of consecutive value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/1049836#M14327</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to calcualte running total of only consecutive 1's value.&lt;/P&gt;&lt;P&gt;condition:&lt;/P&gt;&lt;P&gt;1. Date range is selected in date slicer. So date range is always dynamic.&lt;/P&gt;&lt;P&gt;2. Running total should be done in ascending order of date and should be done fir individual resources.&lt;/P&gt;&lt;P&gt;3. whenever 0 is encountered running total should again restart for eg. for resource "abc" for 1/5/2020 Billable value is 0. so for 1/6/2020 running total is again calculated from beginning.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Resource&lt;/TD&gt;&lt;TD&gt;Billable&lt;/TD&gt;&lt;TD&gt;running total&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/2/2020&lt;/TD&gt;&lt;TD&gt;abc&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/3/2020&lt;/TD&gt;&lt;TD&gt;abc&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&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&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/7/2020&lt;/TD&gt;&lt;TD&gt;xyz&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help if anyone knows the logic.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vaishali Rathi&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 06:47:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/1049836#M14327</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-27T06:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: calculate  running total of consecutive value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/1050246#M14339</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this, I'm hoping someone will come up with a more efficient version, but for now, at least you have some solution.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column = 
VAR __date = 'Table'[Date]
VAR __allResource = ALLEXCEPT( 'Table', 'Table'[Resource] ) 
VAR __firstZero =  
    CALCULATE(
        MAX( 'Table'[Date] ),
        __allResource,
        'Table'[Date] &amp;lt;= __date,
        'Table'[Billable] = 0
    )
VAR __start = 
    IF( 
        ISBLANK( __firstZero ),  
        CALCULATE(
            MIN( 'Table'[Date] ),
            __allResource
        ),
        __firstZero
    )
RETURN 
CALCULATE(
    SUM( 'Table'[Billable] ),
    FILTER(
        ALL( 'Table'[Date] ),
        'Table'[Date] &amp;gt;= __start &amp;amp;&amp;amp; 'Table'[Date] &amp;lt;= __date 
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;See the attached for ref as well&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;Best Regards,&lt;BR /&gt;Mariusz&lt;BR /&gt;&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accepting it as the solution&lt;/I&gt;&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;Please feel free to connect with me.&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/mariusz-repczynski-065a7362/" target="_blank"&gt; LinkedIn &lt;/A&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 08:44:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/1050246#M14339</guid>
      <dc:creator>Mariusz</dc:creator>
      <dc:date>2020-04-27T08:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: calculate  running total of consecutive value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/1050520#M14357</link>
      <description>&lt;P&gt;Thanku&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="81408" data-lia-user-login="Mariusz" class="lia-mention lia-mention-user"&gt;Mariusz&lt;/a&gt;&amp;nbsp;for quick reply. Logic is really awsm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I&amp;nbsp; want the logic to work on dynamic date range. Can you please convert&amp;nbsp; your logic in a measure instead of a column. I am a&amp;nbsp; beginner in power bi so finding it hard to convert&amp;nbsp; as of now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a ton &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vaishali&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 10:16:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/1050520#M14357</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-27T10:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: calculate  running total of consecutive value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/1050538#M14358</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No problem, please see the below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
VAR __date = SELECTEDVALUE( 'Table'[Date] )
VAR __allResource = ALLEXCEPT( 'Table', 'Table'[Resource] ) 
VAR __firstZero =  
    CALCULATE(
        MAX( 'Table'[Date] ),
        __allResource,
        'Table'[Date] &amp;lt;= __date,
        'Table'[Billable] = 0
    )
VAR __start = 
    IF( 
        ISBLANK( __firstZero ),  
        CALCULATE(
            MIN( 'Table'[Date] ),
            __allResource
        ),
        __firstZero
    )
RETURN 
CALCULATE(
    SUM( 'Table'[Billable] ),
    FILTER(
        ALL( 'Table'[Date] ),
        'Table'[Date] &amp;gt;= __start &amp;amp;&amp;amp; 'Table'[Date] &amp;lt;= __date 
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;Best Regards,&lt;BR /&gt;Mariusz&lt;BR /&gt;&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accepting it as the solution&lt;/I&gt;&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;Please feel free to connect with me.&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/mariusz-repczynski-065a7362/" target="_blank"&gt; LinkedIn &lt;/A&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 10:23:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/1050538#M14358</guid>
      <dc:creator>Mariusz</dc:creator>
      <dc:date>2020-04-27T10:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: calculate  running total of consecutive value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/1050799#M14374</link>
      <description>&lt;P&gt;Thanku &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="81408" data-lia-user-login="Mariusz" class="lia-mention lia-mention-user"&gt;Mariusz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I have a&amp;nbsp; concern. In measure _firstzero and _start variable are not getting adjusted with slider date selections at UI.&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vaishali Rathi&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 27 Apr 2020 12:26:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/1050799#M14374</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-27T12:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: calculate  running total of consecutive value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/1052894#M14428</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ok, I've added ALLSELECTED&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
VAR __date = SELECTEDVALUE( 'Table'[Date] )
VAR __allResource = 
    CALCULATETABLE(
        'Table',
        ALLSELECTED( 'Table' ),
        VALUES( 'Table'[Resource] ) 
    )
VAR __firstZero =  
    CALCULATE(
        MAX( 'Table'[Date] ),
        __allResource,
        'Table'[Date] &amp;lt;= __date,
        'Table'[Billable] = 0
    )
VAR __start = 
    IF( 
        ISBLANK( __firstZero ),  
        CALCULATE(
            MIN( 'Table'[Date] ),
            __allResource
        ),
        __firstZero
    )
RETURN 
CALCULATE(
    SUM( 'Table'[Billable] ),
    FILTER(
        ALL( 'Table'[Date] ),
        'Table'[Date] &amp;gt;= __start &amp;amp;&amp;amp; 'Table'[Date] &amp;lt;= __date 
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;Best Regards,&lt;BR /&gt;Mariusz&lt;BR /&gt;&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accepting it as the solution&lt;/I&gt;&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;Please feel free to connect with me.&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/mariusz-repczynski-065a7362/" target="_blank"&gt; LinkedIn &lt;/A&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 07:43:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/1052894#M14428</guid>
      <dc:creator>Mariusz</dc:creator>
      <dc:date>2020-04-28T07:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: calculate  running total of consecutive value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/2779244#M86922</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/user/viewprofilepage/user-id/81408" target="_self"&gt;&lt;SPAN class=""&gt;Mariusz&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am stuck with a similar kind of problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have a table with columns (example dataset&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://1drv.ms/x/s!Aq4U31UFU1WmglcvljNejBWpAjm0?e=faDeWe" target="_blank" rel="nofollow noopener noreferrer"&gt;Mock_PBI (1).xlsx&lt;/A&gt;) - date of Purchase, Product ID, Product Price, and Product Number.&lt;/P&gt;&lt;P&gt;I am working on finding consecutive dates for each Product ID and then sum up the product price for those dates.&lt;SPAN&gt;&amp;nbsp;The result would be something like:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;It would be Really great if you can help me with the problem.&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 03:22:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-running-total-of-consecutive-value/m-p/2779244#M86922</guid>
      <dc:creator>rnd2789</dc:creator>
      <dc:date>2022-09-20T03:22:51Z</dc:date>
    </item>
  </channel>
</rss>

