title: Why does this code work for counting one item in a list but not the others?
body: <p>I am using trying to count the number of "Manager"'s "MIT"'s and "Instore"'s in a .csv file. The code I have works for finding all the "Manager"'s but wont work for the other two.</p>
  
  <p>I've tried splitting the function up into 3 separate functions as I thought the problem may have been using more than one dc.numberDisplay in a function but that didn't work. I've tried the function so there's only one, if it's looking for Managers it works, MIT's it does not and Instores it does not. I've tried changing the order of the code and still nothing. I've put console.log(p.mit_count) within each line of add_item, remove_item and initialise. I've put console.log(d.value.mit_count) within the valueAccessor.</p>
  
  <pre><code>Scott,Instore,3,BMC,96
  Mark,Instore,4,Intro,94
  Wendy,Instore,3,Intro,76
  Lucas,Instore,2,Intro,96
  </code></pre>
  
  <pre><code>    .defer(d3.csv, "data/Results.csv")
      .await(makeGraphs)
  
  //function for making and rendering graphs
  function makeGraphs(error, staffData) {
      var ndx = crossfilter(staffData);
      show_number_of_staff(ndx);
      dc.renderAll();
  }
  
  function show_number_of_staff(ndx) {
      var dim = ndx.dimension(dc.pluck('Rank'));
  
      function add_item(p, v) {
          if (v.Rank == "Manager") {
              p.manager_count++;
          }
          else if (v.Rank == "MIT") {
              p.mit_count++;
          }
          else if (v.Rank == "Instore") {
              p.instore_count++;
          }
          return p;
      }
  
      function remove_item(p, v) {
          if (v.Rank == "Manager") {
              p.manager_count--;
          }
          else if (v.Rank == "MIT") {
              p.mit_count--;
          }
          else if (v.Rank == "Instore") {
              p.instore_count--;
          }
          return p;
      }
  
      function initialise(p, v) {
          return { manager_count: 0, mit_count: 0, instore_count: 0 };
  
      }
  
      var staffCounter = dim.group().reduce(add_item, remove_item, initialise);;
  
      dc.numberDisplay("#managerCount")
          .formatNumber(d3.format(".0"))
          .valueAccessor(function(d) {
              return d.value.manager_count;
          })
          .group(staffCounter);
  
      dc.numberDisplay("#mitCount")
          .formatNumber(d3.format(".0"))
          .valueAccessor(function(d) {
              return d.value.mit_count;
          })
          .group(staffCounter);
  
      dc.numberDisplay("#instoreCount")
          .formatNumber(d3.format(".0"))
          .valueAccessor(function(d) {
              return d.value.instore_count;
          })
          .group(staffCounter);
  }
  </code></pre>
  
  <p><code>console.log(p.mit_count)</code> shows that it counts to 13 (as I am expecting it to), but then in the <code>valueAccessor</code> <code>console.log(d.value.mit_count)</code> shows 0. I cannot get why this works for "Manager" but nothing else. I'm almost embarrassed that this has taken me over a week. It just seems so simple!</p>