title: Dynamic GETPIVOTDATA formula to SUM with different date ranges per column
body: <p>I have below an example pivot table with Countries as my columns, and Dates as my rows. The data for this pivot is based on A1:C13. Cells F1:G3 is what the user of this model can adjust. They can change the country and/or the date ranges.</p>
  <p>What I am needing is a <strong>single formula to output the total of their selection</strong>. As my actual data set contains many countries, simply writing an nested IF statement won't suffice. The dataset also needs to be in pivot table - hence the GETPIVOTDATA requirement.</p>
  <p>I've gotten about half of the way there using this formula here:</p>
  <pre><code>=SUM(GETPIVOTDATA(&quot;Sum of Value&quot;,$A$15,&quot;Date&quot;,ROW(INDIRECT(F2&amp;&quot;:&quot;&amp;F3)),&quot;Country&quot;,F1:G1))
  </code></pre>
  <p>The problem here is that this formula is not dynamic for the differing date selections per country.</p>
  <p>Can anyone assist?</p>
  <p><a href="https://i.stack.imgur.com/xeTdR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xeTdR.png" alt="enter image description here" /></a></p>