title: Find earliest and latest timestamp per day, created calculated column with time in between
body: <p>I'm fairly new to DAX &amp; PowerBI and I'm trying to wrap my head around how I can determine and calculate timeframes per day.</p>
  <p>The Goal:</p>
  <ul>
  <li>Get the minimum and maximum timestamps for each day in the data set</li>
  <li>Calculate the time difference between the two in HH:MM</li>
  <li>Created a calculated column to store the HH:MM result</li>
  </ul>
  <p>So far I have found the following two DAX queries to work when creating a calculated column of the min and max timestamps:</p>
  <pre><code>CALCULATE(MIN('Packing Jobs - Pick Lines'[Timestamp]),FILTER('Packing Jobs - Pick Lines',FORMAT([Timestamp],&quot;DD-MM-YYYY&quot;)=FORMAT(EARLIER([Timestamp]),&quot;DD-MM-YYYY&quot;)))
  
  CALCULATE(MAX('Packing Jobs - Pick Lines'[Timestamp]),FILTER('Packing Jobs - Pick Lines',FORMAT([Timestamp],&quot;DD-MM-YYYY&quot;)=FORMAT(EARLIER([Timestamp]),&quot;DD-MM-YYYY&quot;)))
  </code></pre>
  <p>However I am having a hard time trying to calculate and store the difference between the two results. I do not seem to be able to call the calculated columns when creating a new column to calculate, and when I have tried to combine them into the same column creation, the results are far from accurate.</p>
  <pre><code>Column = 
  VAR firstscan =
      CALCULATE(MIN('Packing Jobs - Pick Lines'[Timestamp]),FILTER('Packing Jobs - Pick Lines',FORMAT([Timestamp],&quot;DD-MM-YYYY HH:MM&quot;)=FORMAT(EARLIER([Timestamp]),&quot;DD-MM-YYYY HH:MM&quot;)))
  VAR lastscan =
      CALCULATE(MAX('Packing Jobs - Pick Lines'[Timestamp]),FILTER('Packing Jobs - Pick Lines',FORMAT([Timestamp],&quot;DD-MM-YYYY HH:MM&quot;)=FORMAT(EARLIER([Timestamp]),&quot;DD-MM-YYYY HH:MM&quot;)))
  
  RETURN
      CALCULATE(lastscan - firstscan)
  </code></pre>
  <p>I have tried with and without and <code>HH:MM</code> and the result still shows me in 1899 for every line. Any advice or pointers would be amazing!</p>