title: Need an array formula to calculate average across a column, excluding zeroes
body: <p>I have this dataset in an Excel table:
  <a href="https://i.stack.imgur.com/aFYAu.png" rel="nofollow"><img src="https://i.stack.imgur.com/aFYAu.png" alt="enter image description here"></a><br>
  I want to calculate the average number of times a product was bought across all customers, where the customer has bought it at least once and I want to store the result in another column, in column D.</p>
  
  <p>So for example... 2 Customers have bought "Cheddar Mature", one of them bought it 3 times and one of them bought it 5 times (highlighted above). Hence the value I want to calculate is (3+5)/2 = 4, and I want that value to be stored in cells D3, D4, D5, D6 &amp; D7.</p>
  
  <p>I know that I need an array formula to figure this out but I can't get my array formula correct. Here's what I have got so far:</p>
  
  <p><code>{=AVERAGE(IF([Product]=[@Product],[Number Of Times Bought],0))}</code></p>
  
  <p>Here is the result that gives me....not what I want:</p>
  
  <p><a href="https://i.stack.imgur.com/IEMLd.png" rel="nofollow"><img src="https://i.stack.imgur.com/IEMLd.png" alt="enter image description here"></a>  </p>
  
  <p>As you can see the answer in those cells is 0.615384615 which (I've worked out) has been derived by dividing by the total number of rows in the table i.e. (3 + 5) / 13 = 0.615384615.</p>
  
  <p>So, I need my array formula to only divide by the number of rows which have a non-zero value for sales of "Cheddar Mature". Can anyone figure that out?</p>
  
  <p>To help, I have made the workbook available on my OneDrive for anyone that wants to try and solve this: <a href="https://1drv.ms/x/s!AjcmU60daA9VqqgSJkQ_ewOGPqkAMA" rel="nofollow">https://1drv.ms/x/s!AjcmU60daA9VqqgSJkQ_ewOGPqkAMA</a></p>