title: Group by and aggregation on JSON array using Underscore JS
body: <p>I have a json array object . I want to group by data based on column "FlexCategoryName" and perform aggregation on  matrix columns such as avg of "cost" ,sum of "clicks" etc . Below are JSON array Object </p>
  
  <pre><code>Array[100]
  0: Object
  1: Object
  2: Object
  3: Object
  </code></pre>
  
  <p>0: Object</p>
  
  <pre><code>Clicks: 1067
  Cost: 4094.2
  Date: "2/8/2014"
  FlexCategoryName: "Cat1"
  Impressions: 65943
  Leads: 20
  </code></pre>
  
  <p>VENUE_ID:1</p>
  
  <p>1: Object</p>
  
  <pre><code>Clicks: 106
  Cost: 409
  Date: "2/8/2014"
  FlexCategoryName: "Cat2"
  Impressions: 65941
  Leads: 21
  VENUE_ID:1
  </code></pre>
  
  <p>2: Object</p>
  
  <pre><code>Clicks: 106
  Cost: 409
  Date: "2/8/2014"
  FlexCategoryName: "Cat2"
  Impressions: 10
  Leads: 21
  VENUE_ID:2
  </code></pre>
  
  <p>3: Object</p>
  
  <pre><code>Clicks: 106
  Cost: 409
  Date: "2/8/2014"
  FlexCategoryName: "Cat3"
  Impressions: 10
  Leads: 21
  VENUE_ID:2
  </code></pre>
  
  <p>4: Object</p>
  
  <pre><code>Clicks: 20
  Cost: 10
  Date: "2/8/2014"
  FlexCategoryName: "Cat5"
  Impressions: 10
  Leads: 21
   VENUE_ID:3
  </code></pre>
  
  <p>How to use Underscore JS to perform group by and aggregation on matrix columns .</p>
  
  <p>Expected Output</p>
  
  <pre><code>0: Object
  Cost: sum of all cost based on FlexCategoryName Cat1
  FlexCategoryName: "Cat1"
  Impressions: sum of all Impressions based on FlexCategoryName Cat1
  
  1: Object
  Cost: sum of all cost based on FlexCategoryName Cat2
  FlexCategoryName: "Cat2"
  Impressions: sum of all Impressions based on FlexCategoryName Cat2
  </code></pre>