title: Google sheet -> filtering a query
body: <p>I created the following sheet:</p>
  
  <p><a href="https://docs.google.com/spreadsheets/d/1AJmzlBlrDZ0mfb_9aSm83fzZxrwYWOxWGxjNhlfqPLA/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1AJmzlBlrDZ0mfb_9aSm83fzZxrwYWOxWGxjNhlfqPLA/edit?usp=sharing</a></p>
  
  <p><a href="https://i.stack.imgur.com/GuxYk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GuxYk.jpg" alt=""></a></p>
  
  <p>I am trying to find a formula to calculate the totals (C7, C8, C9) and wherever it is copied ie C17, C18, C19)</p>
  
  <p>So for C7 I want to sum column D (Duration) wherever:</p>
  
  <ul>
  <li>the Date (col A) is the same as the total row date (that is A7)</li>
  <li>The Category (col E) is Internal</li>
  </ul>
  
  <p>Similarly for So for C8 I want to sum column D (Duration) wherever:</p>
  
  <ul>
  <li>the Date (col A) is the same as the total row date (that is A8)</li>
  <li>The Category (col E) is External</li>
  </ul>
  
  <p>and </p>
  
  <p>for C9 I want to sum column D (Duration) wherever:</p>
  
  <ul>
  <li>the Date (col A) is the same as the total row date (that is A9)</li>
  <li>Has any category</li>
  </ul>
  
  <p>I tried for C7 -</p>
  
  <pre><code>=QUERY({A:E, arrayformula(N(D:D))}, "select sum(Col6) where Col5='Internal' and Col1 = " &amp; A7 &amp; " label sum(Col6) ''",1)
  </code></pre>
  
  <p>but I get NA ??? any help ?
   - </p>