title: Google Sheets: How to make a stacked/aggregate chart
body: <p>I have made a bar chart which aggregates my data, but is there any way I can split each bar based on the data it is aggregating - similar to how a stacked bar chart would look?</p>
  <p>Here is a bad artists impression (thick blue lines mine). The idea is that it's important to know from looking at the graph if I sold 5 at £1, or 1 at £5.</p>
  <p><a href="https://i.stack.imgur.com/NONzb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NONzb.png" alt="What I want...." /></a></p>
  <p>Ideally this would work even if the price for each item is variable, but that is not essential (eg: if there is a 'hack' with hardcoding Apple = 3, I can live with that.)</p>
  <p>I'm also fine inputting helper columns etc, within reason, but I would want to be able to easily continue to add things to the list on the left without having to add <em>new</em> helper columns each time (calculated ones are fine, of course.)</p>
  <p>Thanks in advance.</p>
  <p><strong>UPDATE:</strong> With thanks to Kin Siang below, I ended up implementing a slightly modified version of their solution, which I am posting here for completeness.</p>
  <p>I added a very large (but finite) number of helper columns to the right, with a formula in each cell which would look for the nth occurrence of the item in the main list (wrapped in an iferror to make the unused cells blank).</p>
  <pre><code>=iferror(index(FILTER($A:$B,$A:$A=$D2),E$1,2))
  </code></pre>
  <p><a href="https://i.stack.imgur.com/cCFil.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cCFil.png" alt="Solution" /></a></p>
  <p>Theoretically it could run out of space one day, but I have made it suitably large that this should not be an issue. It has the advantage over the other solution that I do not need to sort or otherwise manipulate the input range and can continue trickling in data to the main list and have the chart automatically update.</p>