<?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: I don't understand how running total works in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2776047#M86681</link>
    <description>&lt;P&gt;Thanks for your reply. It still sounds a little black box-y to me. Take this line:&lt;/P&gt;&lt;PRE&gt;'Date'[Date] &amp;lt;= __Max&lt;/PRE&gt;&lt;P&gt;Am I right to understand that __Max is determined by the outer filter context in the UI? And then 'Date'[Date] is what FILTER iterates?&lt;/P&gt;&lt;P&gt;So in essence, FILTER produces a longer and longer table: row 1, row 1&lt;SPAN&gt;–&lt;/SPAN&gt;2, row 1&lt;SPAN&gt;–&lt;/SPAN&gt;3, row 1&lt;SPAN&gt;–&lt;/SPAN&gt;4 etc.&lt;/P&gt;</description>
    <pubDate>Sun, 18 Sep 2022 18:42:04 GMT</pubDate>
    <dc:creator>daanodinot</dc:creator>
    <dc:date>2022-09-18T18:42:04Z</dc:date>
    <item>
      <title>I don't understand how running total works</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2775967#M86675</link>
      <description>&lt;P&gt;I've been knocking my against the wall for hours, but I just can't understand how this measure works:&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;Running Total = 
CALCULATE (
    [Total Sales],
    FILTER ( 
        ALL ( 'Date' ), 
        'Date'[Date] &amp;lt;= MAX ( 'Date'[Date] ) 
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This indeed produces a running total, but I don't know why!&lt;/P&gt;&lt;P&gt;ALL ignores any filters. So why isn't the result of MAX always the max of the whole table? And subsequently, why isn't the result of this measure always the total sales of the whole table? The &lt;A href="https://www.sqlbi.com/articles/understanding-context-transition-in-dax/" target="_self"&gt;article&lt;/A&gt;&amp;nbsp;says:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;In &lt;EM&gt;RT Sales 2&lt;/EM&gt; [which I've renamed to Running Total for simplicity]&lt;/SPAN&gt;&lt;SPAN&gt;, on the other hand,&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://dax.guide/max/?aff=sqlbi" target="_blank" rel="noopener"&gt;MAX&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;is executed without a&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://dax.guide/calculate/?aff=sqlbi" target="_blank" rel="noopener"&gt;CALCULATE&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;around it. So it computes the max date in the outer filter context, created by the visual through&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://dax.guide/summarizecolumns/?aff=sqlbi" target="_blank" rel="noopener"&gt;SUMMARIZECOLUMNS&lt;/A&gt;&lt;SPAN&gt;. As such, it computes the last visible date in the visual, and produces the correct result.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Can anyone explain step by step what Power BI does to get the running total? I still don't get it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Sep 2022 17:16:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2775967#M86675</guid>
      <dc:creator>daanodinot</dc:creator>
      <dc:date>2022-09-18T17:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: I don't understand how running total works</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2775985#M86678</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="439603" data-lia-user-login="daanodinot" class="lia-mention lia-mention-user"&gt;daanodinot&lt;/a&gt;&amp;nbsp;Well, whether it works or not is dependent on which column you use from your data model. Use the wrong column and you get the wrong answer. You could write this perhaps more clearly as below. So, get the max date in the current context. So if you have a month as your axis then in March this would return 3/12/2022 for example. Then you are using the ALL to break the current context and put all rows in "view". Then you simply filter for dates &amp;lt; your maximum date and perform your calculation in that context. If you want a much more ledgeable way of doing this that in my opinion is better and doesn't use all the esoteric CALCULATE craziness, watch this video.&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=meh3OkgFYfc&amp;amp;t=24s" target="_blank" rel="noopener"&gt;MSHGQM - Don't Use CALCULATE! - YouTube&lt;/A&gt;. Simple, understandable, makes sense versus black box magic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Running Total = 
VAR __Max = MAX('Date'[Date])
RETURN
CALCULATE (
    [Total Sales],
    FILTER ( 
        ALL ( 'Date' ), 
        'Date'[Date] &amp;lt;= __Max ) 
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Sep 2022 17:58:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2775985#M86678</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2022-09-18T17:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: I don't understand how running total works</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2776047#M86681</link>
      <description>&lt;P&gt;Thanks for your reply. It still sounds a little black box-y to me. Take this line:&lt;/P&gt;&lt;PRE&gt;'Date'[Date] &amp;lt;= __Max&lt;/PRE&gt;&lt;P&gt;Am I right to understand that __Max is determined by the outer filter context in the UI? And then 'Date'[Date] is what FILTER iterates?&lt;/P&gt;&lt;P&gt;So in essence, FILTER produces a longer and longer table: row 1, row 1&lt;SPAN&gt;–&lt;/SPAN&gt;2, row 1&lt;SPAN&gt;–&lt;/SPAN&gt;3, row 1&lt;SPAN&gt;–&lt;/SPAN&gt;4 etc.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Sep 2022 18:42:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2776047#M86681</guid>
      <dc:creator>daanodinot</dc:creator>
      <dc:date>2022-09-18T18:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: I don't understand how running total works</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2776093#M86683</link>
      <description>&lt;LI-CODE lang="markup"&gt;Running Total = 
CALCULATE (
    [Total Sales],
    FILTER ( 
        ALL ( 'Date' ),    -- apply on a table, filter not changed
        'Date'[Date] &amp;lt;= MAX ( 'Date'[Date] )  -- max date in the current context
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filter is an iterator.&lt;/P&gt;&lt;P&gt;So formula will iterate thru date table ( all dates in this case) and sum up the sales&lt;/P&gt;&lt;P&gt;until date is &amp;lt;= to max date in the current context.&lt;/P&gt;&lt;P&gt;Context can come from calculate , filter, visual filter, ....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Formula will be executed for each line in the visual&lt;/P&gt;&lt;P&gt;so if, in the visual you have&lt;/P&gt;&lt;P&gt;01/2022 : sumup until 01/2022&lt;/P&gt;&lt;P&gt;02/2022 - sumup until 02/2022 and so&amp;nbsp; on&lt;/P&gt;&lt;P&gt;And the total will be calculated in the same way - sumup sales for all the dates. It is not calculated by summing the rows.&lt;/P&gt;&lt;P&gt;All rows are calculated in their context.&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/filter-context-in-dax/" target="_blank"&gt;Filter context in DAX - SQLBI&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Sep 2022 20:57:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2776093#M86683</guid>
      <dc:creator>latimeria</dc:creator>
      <dc:date>2022-09-18T20:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: I don't understand how running total works</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2776858#M86713</link>
      <description>&lt;P&gt;Thank you. I think it's starting to click now.&lt;/P&gt;&lt;P&gt;Should I see it that MAX is always the MAX of te whole table inside FILTER and &lt;EM&gt;then&lt;/EM&gt; the visual filter is applied? Or is the MAX already determined by the visual filter &lt;EM&gt;going into&lt;/EM&gt;&amp;nbsp;FILTER?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 07:37:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2776858#M86713</guid>
      <dc:creator>daanodinot</dc:creator>
      <dc:date>2022-09-19T07:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: I don't understand how running total works</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2778645#M86883</link>
      <description>&lt;P&gt;To master the DAX, you need to understand&amp;nbsp;&lt;/P&gt;&lt;P&gt;Row context&lt;/P&gt;&lt;P&gt;Filter context&lt;/P&gt;&lt;P&gt;Context transition (tough to understand).&lt;/P&gt;&lt;P&gt;variables&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/understanding-context-transition-in-dax/" target="_blank"&gt;Understanding context transition in DAX - SQLBI&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/filter-context-in-dax/" target="_blank"&gt;Filter context in DAX - SQLBI&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/row-context-in-dax/" target="_blank"&gt;Row context in DAX - SQLBI&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/variables-in-dax/" target="_blank"&gt;Variables in DAX - SQLBI&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=P9Q3I9QGjGY" target="_blank"&gt;https://www.youtube.com/watch?v=P9Q3I9QGjGY&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=pTI2ASgecGA" target="_blank"&gt;https://www.youtube.com/watch?v=pTI2ASgecGA&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=sOMhqaaWM9Y" target="_blank"&gt;https://www.youtube.com/watch?v=sOMhqaaWM9Y&lt;/A&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;</description>
      <pubDate>Mon, 19 Sep 2022 20:16:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2778645#M86883</guid>
      <dc:creator>latimeria</dc:creator>
      <dc:date>2022-09-19T20:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: I don't understand how running total works</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2778730#M86888</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="439603" data-lia-user-login="daanodinot" class="lia-mention lia-mention-user"&gt;daanodinot&lt;/a&gt;&amp;nbsp;It is black boxy, it's CALCULATE. It's one of the reasons I don't use it. There are far simpler running totals out there. LIke this one for instance (below). I separated out the MAX into it's own VAR to make clear that it is getting the MAX in the current context of the visual where it is being executed. However, the method in the video demonstrates a better, more clear, method IMHO. As in:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Better RT 2 = 
    VAR __Date = MAX('Dates'[Date])
    VAR __Table = FILTER(ALLSELECTED('Table'),[Date] &amp;lt;= __Date)
RETURN
    SUMX(__Table,[Value])&lt;/LI-CODE&gt;
&lt;P&gt;In other words, get the maximum date in context, so let's say you have a column chart with year and month as the axis. March in 2022 would give you March 31st, 2022. Then you just filter everything in your table that is less than that date. (The ALLSELECTED preserves things like maybe a Year slicer). Then you simply perform a SUMX across that table for the value you want. And yes, April is going to return more rows than March and May more rows than April, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 21:18:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2778730#M86888</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2022-09-19T21:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: I don't understand how running total works</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2785000#M87256</link>
      <description>&lt;P&gt;I'm trying - and I'm familiar with most of those resources. If you want to be more helpful, please try to answer my specific question. I think a lot of learning comes from understanding these small examples.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 19:44:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-don-t-understand-how-running-total-works/m-p/2785000#M87256</guid>
      <dc:creator>daanodinot</dc:creator>
      <dc:date>2022-09-21T19:44:39Z</dc:date>
    </item>
  </channel>
</rss>

