title: How to sum values of rows based of query in another column of that row?
body: <p>In the table below, I'd like to write a query in each <code>{calc}</code> cell that will use the <code>name</code> column to look up a value and sum the column based off the percentage in each cell.</p>
  
  <p>For example for each row in <code>month1</code>, <code>month2</code>, <code>month3</code>, etc., I'd like to query another sheet based off the <code>name</code> and then sum up the results. </p>
  
  <p>I'm less worried about the math or the query itself, but more interested in how to reference a index/iteration of a query to sum up all the rows. During a <code>SUM</code> operation, is there a way to reference the current index/row being summed and make a query based off that?</p>
  
  <pre><code>+----------------------+--------------+--------------+--------------+
  |         name         |    month1    |    month2    |   month 3    |
  +----------------------+--------------+--------------+--------------+
  |                      | {calc-1}     | {calc-2}     | {calc-3}     |
  | name1                | 65%          | 100%         | 85%          |
  | name2                | 100%         | 100%         | 90%          |
  | name3                | 100%         | 100%         | 80%          |
  +----------------------+--------------+--------------+--------------+
  </code></pre>
  
  <p>Example sheet where formulas could be run.</p>
  
  <pre><code>+-------+--------+
  | name  | number |
  +-------+--------+
  | name1 |     10 |
  | name2 |     20 |
  | name3 |      5 |
  +-------+--------+
  </code></pre>
  
  <p>The output for <code>{calc-1}</code> would be the SUM of 65% of 10, 100% of 20, 100% 0f 5 and so on.  <code>calc-1 = 31.5</code> And I'd like to run this for each month.</p>