title: Yesterday Sales Amount
body: <p>We can assume that Yesterday will be the <em>last non blank date in the Sales table</em></p>
  
  <p>How do I add the above logic into the following measure?</p>
  
  <pre><code>Yesterday Sales = 
  CALCULATE(
      SUM(Sales[SalesAmount])
      , LASTDATE('Calendar'[Date])
  )  
  </code></pre>
  
  <p>Currently this measure returns the following:</p>
  
  <p><a href="https://i.stack.imgur.com/wRq7y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wRq7y.png" alt="enter image description here"></a></p>
  
  <p>This makes sense as the last date in the calendar table is not in the Sales table - so I think I need to change <code>LASTDATE('Calendar'[Date])</code> so it only returns the last date that is in the Sales table - how do I do this?</p>
  
  <hr>
  
  <p>note</p>
  
  <p>There is a relationship between the Calendar and Sales table based on a Datekey but there is no Date column in the Sales table.</p>