title: DAX running total + starting value
body: <p>I am fairly new to the DAX universe, but scrolling around I managed to successfully implement a cumulative (running) total, with a measure defined along this structure:   <code>Running_Total_QTY:=CALCULATE(SUM(Reporting[QTY]),FILTER(ALL(Reporting[DATE_R]),Reporting[DATE_R]&lt;=MAX(Reporting[DATE_R])))</code></p>
  
  <p>For a table that looks like this:</p>
  
  <pre><code>ID  DATE_R          QTY
  A1  5/11/2018 9:00  5
  A1  5/11/2018 9:01  10
  A1  5/11/2018 9:01  -5
  A1  5/11/2018 9:02  50
  A1  5/11/2018 9:05  -20
  B1  5/11/2018 9:00  3
  B1  5/11/2018 9:01  -20
  B1  5/11/2018 9:01  4
  B1  5/11/2018 9:02  20
  B1  5/11/2018 9:03  10
  </code></pre>
  
  <p>The problem is that I would need to add to this running total a starting QTY - <em>QTY_INIT</em>, which I receive from another table that looks like this:</p>
  
  <pre><code>ID1 QTY_INIT
  A1  100
  B1  200
  </code></pre>
  
  <p>By trial and error I have succeeded by creating a second measure that calculates the average (of 1 item!) defined like this:</p>
  
  <pre><code>Average_starting_quantity:=CALCULATE(AVERAGE(Starting_Quantity[QTY_INIT]),FILTER(ALL(Starting_Quantity[ID1]),Starting_Quantity[ID1]=LASTNONBLANK(Reporting[ID],TRUE())))
  </code></pre>
  
  <p>And then just adding the two measures together. </p>
  
  <pre><code>Running_plus_total:=[Running_Total_QTY]+[Average_starting_quantity]
  </code></pre>
  
  <p>This method works, but is very inefficient and very slow (the data set is quite big). </p>
  
  <p>How can I add QTY_INIT from the second table directly without using a "fake" average (or max, min, etc..)? How can I optimize the measure for a faster performance?</p>
  
  <p>Thanks in advance for any help. </p>
  
  <p>Regards</p>