title: how to I fix my table about distinct and count in ASP.NET MVC
body: <p>I have trouble about my table and about my Count and Distinct</p>
  
  <p>this for my RazorView</p>
  
  <pre><code>&lt;table id="example2" class="table table-bordered table-striped"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th rowspan="2"&gt;Tahun&lt;/th&gt;
              &lt;th colspan="2"&gt;Jml. F1&lt;/th&gt;
              &lt;th rowspan="2"&gt;Jml. F2 PR&lt;/th&gt;
              &lt;th rowspan="2"&gt;Jml. F2 PE&lt;/th&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;Sementara&lt;/th&gt;
              &lt;th&gt;Tetap&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          @foreach (var item in Model.rol_tb_form1List.Select(x =&gt; x.tgl_moc.Year).Distinct())
              {
                  &lt;tr&gt;
                      &lt;td&gt;@Html.DisplayFor(x =&gt; item)&lt;/td&gt;  
                  &lt;/tr&gt;
              }
          @foreach (var form1 in Model.rol_tb_form1List.Where(y =&gt; y.jenis_perubahan == "sementara").GroupBy(x =&gt; x.tgl_moc.Year))
              {
                  &lt;tr&gt;
                       &lt;td&gt;@Html.DisplayFor(x =&gt; form1).ToString().Count()&lt;/td&gt;
                  &lt;/tr&gt;
              }
          @foreach (var form1 in Model.rol_tb_form1List.Where(y =&gt; y.jenis_perubahan == "tetap").GroupBy(x =&gt; x.tgl_moc.Year))
              {
                  &lt;tr&gt;
                       &lt;td&gt;@Html.DisplayFor(x =&gt; form1).ToString().Count()&lt;/td&gt;
                  &lt;/tr&gt;
              }
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>can someone fix my code about my table or my Count or my Distinct..</p>
  
  <p>sorry about my bad english</p>
  
  <p>this foy my Controller</p>
  
  <pre><code>public ActionResult Rekap()
      {
          Setting setting = new Setting();
          setting.rol_tb_form1List = db.rol_tb_form1.ToList();
          return View(setting);
      }
  </code></pre>
  
  <p>I just use a simple Controller but I dont know this right or not..</p>
  
  <p>result for that code</p>
  
  <p><a href="https://i.stack.imgur.com/ant7h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ant7h.png" alt="enter image description here"></a></p>
  
  <p>I want value <code>19 18 42 49</code> in column Sementara and value <code>377 363 63 13</code> in column Tetap</p>
  
  <p>this for my example data, this just example</p>
  
  <p><a href="https://i.stack.imgur.com/rULhS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rULhS.png" alt="enter image description here"></a></p>
  
  <p>and I want result for thats example is like this</p>
  
  <p><a href="https://i.stack.imgur.com/Qwh70.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qwh70.png" alt="enter image description here"></a></p>