title: Google Sheets: generating a filtered array and doing a sumif in the same formula
body: <p>I have a document with a column (<code>'Source'!D:D</code>) built with this formatting:</p>
  
  <pre><code>Country → Name → ID
  Country → Name → ID
  Country → Name → ID
  Country → Name → ID
  </code></pre>
  
  <p>In the same document, there's another column (<code>'Source'!AA:AA</code>) with numbers. I'd like to sum the numbers if the Country in <code>ColD</code> is for example USA. I can't add columns in the <code>Source</code> document, so I need to generate an array with the countries already "polished" inside the formula.
  I've tried with this, but it's not working. The ARRAYFORMULA and REGEXTRACT definitely work (the standalone bit indeed generates an array with only country names), but I think the 2 criteria "don't talk to each other", they're like separated bits, not referring to the same row anymore.</p>
  
  <pre><code>=SUMIFS('Source'!$AA$100:$AA,arrayformula(REGEXEXTRACT(ARRAYFORMULA('Source'!$D$100:$D), "^(.+?)→")),"USA")
  </code></pre>
  
  <p>How can I change the formula above to work?</p>