title: AWS Quicksight - How do I group by sum and then average?
body: <p>I've just started using Quicksight and I can't for the life of me figure this out.</p>
  <p>Let's say I have a table that goes like this :</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>date</th>
  <th>country</th>
  <th>color</th>
  <th>nb_sales</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>10-11</td>
  <td>USA</td>
  <td>Black</td>
  <td>10</td>
  </tr>
  <tr>
  <td>10-11</td>
  <td>USA</td>
  <td>Blue</td>
  <td>5</td>
  </tr>
  <tr>
  <td>10-12</td>
  <td>USA</td>
  <td>Blue</td>
  <td>20</td>
  </tr>
  <tr>
  <td>10-11</td>
  <td>UK</td>
  <td>Black</td>
  <td>10</td>
  </tr>
  <tr>
  <td>10-12</td>
  <td>UK</td>
  <td>Black</td>
  <td>15</td>
  </tr>
  <tr>
  <td>10-11</td>
  <td>UK</td>
  <td>Blue</td>
  <td>15</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>What I want is the average daily number of sales by country, preferably in a pieplot :</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>country</th>
  <th>avg_nb_sales</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>USA</td>
  <td>17.5</td>
  </tr>
  <tr>
  <td>UK</td>
  <td>20</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>So I need first to group by date, country and sum the ratings and then once this aggregation is done I need the average by country. I thought I should be using avgOver(sum(ratings), country) but I can't get it right.</p>
  <p>So how do I achieve that ?</p>
  <p>I thank you for your time.</p>