<?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: Reset cummulative total/running total when other column value is TRUE in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Reset-cummulative-total-running-total-when-other-column-value-is/m-p/2573256#M73591</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="299999" data-lia-user-login="justlogmein" class="lia-mention lia-mention-user"&gt;justlogmein&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Hope it's not too late &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is the sample file with the solution&amp;nbsp;&lt;A href="https://www.dropbox.com/t/HZEL59KsSFlicaPV" target="_blank"&gt;https://www.dropbox.com/t/HZEL59KsSFlicaPV&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;Please use the following code&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Fluid Hours Reset when Oil Changed = 
IF ( 
    'Sample Data'[Oil Changed] = FALSE ( ),
    VAR CurrentDate = 'Sample Data'[Sample Date]
    VAR DatesBeforeTable1 = FILTER ( 'Sample Data', 'Sample Data'[Sample Date] &amp;lt;= CurrentDate )
    VAR DatesBeforeTable2 = FILTER ( 'Sample Data', 'Sample Data'[Sample Date] &amp;lt; CurrentDate )
    VAR PrevuiousChangesTable = FILTER ( DatesBeforeTable2, 'Sample Data'[Oil Changed] = TRUE ( ) )
    VAR PreviousChangeDate = MAXX ( PrevuiousChangesTable, 'Sample Data'[Sample Date] )
    VAR ResultTable = FILTER ( DatesBeforeTable1, 'Sample Data'[Sample Date] &amp;gt; PreviousChangeDate )
    RETURN
        SUMX (
            ResultTable,
            'Sample Data'[Hours Since Previous Reading]
        )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;If you want to include the last change hours with the sum use this code with a very tiny change&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Fluid Hours Reset when Oil Changed = 
IF ( 
    'Sample Data'[Oil Changed] = FALSE ( ),
    VAR CurrentDate = 'Sample Data'[Sample Date]
    VAR DatesBeforeTable1 = FILTER ( 'Sample Data', 'Sample Data'[Sample Date] &amp;lt;= CurrentDate )
    VAR DatesBeforeTable2 = FILTER ( 'Sample Data', 'Sample Data'[Sample Date] &amp;lt; CurrentDate )
    VAR PrevuiousChangesTable = FILTER ( DatesBeforeTable2, 'Sample Data'[Oil Changed] = TRUE ( ) )
    VAR PreviousChangeDate = MAXX ( PrevuiousChangesTable, 'Sample Data'[Sample Date] )
    VAR ResultTable = FILTER ( DatesBeforeTable1, 'Sample Data'[Sample Date] &amp;gt;= PreviousChangeDate )
    RETURN
        SUMX (
            ResultTable,
            'Sample Data'[Hours Since Previous Reading]
        )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 12 Jun 2022 14:24:05 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2022-06-12T14:24:05Z</dc:date>
    <item>
      <title>Reset cummulative total/running total when other column value is TRUE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Reset-cummulative-total-running-total-when-other-column-value-is/m-p/2573094#M73580</link>
      <description>&lt;P&gt;What I want to do is pretty straightforward but all the examples I have tried have not worked so far and I'm stressing a little because I need to complete this today.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table of engine oil samples for heavy mining machinery and a column called "Engine Oil Changed" which indicates if the engine oil was changed when that sample was taken. Now I simply want to find out how many hours the oil had before it was changed. I have a running total column for the hours which works fine. I just need to reset this running total when the "Engine Oil Changed" column is true, noting that I need to have it grouped by "Unit Number".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is anyone able to provide some code to put into this column?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://jmservicescomau-my.sharepoint.com/:u:/g/personal/jacob_jmservices_com_au/EaFFuIzsncpKiGoUSuwxrWUBVk8_IllZCqvVeT0G4jeqPg?e=8xJmDN" target="_blank"&gt;https://jmservicescomau-my.sharepoint.com/:u:/g/personal/jacob_jmservices_com_au/EaFFuIzsncpKiGoUSuwxrWUBVk8_IllZCqvVeT0G4jeqPg?e=8xJmDN&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2022 06:26:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Reset-cummulative-total-running-total-when-other-column-value-is/m-p/2573094#M73580</guid>
      <dc:creator>justlogmein</dc:creator>
      <dc:date>2022-06-12T06:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Reset cummulative total/running total when other column value is TRUE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Reset-cummulative-total-running-total-when-other-column-value-is/m-p/2573256#M73591</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="299999" data-lia-user-login="justlogmein" class="lia-mention lia-mention-user"&gt;justlogmein&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Hope it's not too late &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is the sample file with the solution&amp;nbsp;&lt;A href="https://www.dropbox.com/t/HZEL59KsSFlicaPV" target="_blank"&gt;https://www.dropbox.com/t/HZEL59KsSFlicaPV&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;Please use the following code&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Fluid Hours Reset when Oil Changed = 
IF ( 
    'Sample Data'[Oil Changed] = FALSE ( ),
    VAR CurrentDate = 'Sample Data'[Sample Date]
    VAR DatesBeforeTable1 = FILTER ( 'Sample Data', 'Sample Data'[Sample Date] &amp;lt;= CurrentDate )
    VAR DatesBeforeTable2 = FILTER ( 'Sample Data', 'Sample Data'[Sample Date] &amp;lt; CurrentDate )
    VAR PrevuiousChangesTable = FILTER ( DatesBeforeTable2, 'Sample Data'[Oil Changed] = TRUE ( ) )
    VAR PreviousChangeDate = MAXX ( PrevuiousChangesTable, 'Sample Data'[Sample Date] )
    VAR ResultTable = FILTER ( DatesBeforeTable1, 'Sample Data'[Sample Date] &amp;gt; PreviousChangeDate )
    RETURN
        SUMX (
            ResultTable,
            'Sample Data'[Hours Since Previous Reading]
        )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;If you want to include the last change hours with the sum use this code with a very tiny change&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Fluid Hours Reset when Oil Changed = 
IF ( 
    'Sample Data'[Oil Changed] = FALSE ( ),
    VAR CurrentDate = 'Sample Data'[Sample Date]
    VAR DatesBeforeTable1 = FILTER ( 'Sample Data', 'Sample Data'[Sample Date] &amp;lt;= CurrentDate )
    VAR DatesBeforeTable2 = FILTER ( 'Sample Data', 'Sample Data'[Sample Date] &amp;lt; CurrentDate )
    VAR PrevuiousChangesTable = FILTER ( DatesBeforeTable2, 'Sample Data'[Oil Changed] = TRUE ( ) )
    VAR PreviousChangeDate = MAXX ( PrevuiousChangesTable, 'Sample Data'[Sample Date] )
    VAR ResultTable = FILTER ( DatesBeforeTable1, 'Sample Data'[Sample Date] &amp;gt;= PreviousChangeDate )
    RETURN
        SUMX (
            ResultTable,
            'Sample Data'[Hours Since Previous Reading]
        )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2022 14:24:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Reset-cummulative-total-running-total-when-other-column-value-is/m-p/2573256#M73591</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-06-12T14:24:05Z</dc:date>
    </item>
  </channel>
</rss>

