I have an table, the first row stands for months. The next are for the values. I wan't to introduce an aggregation/row calculation method and display it in the last row. Due to the amount of rows and cols, ***I am not quite sure where to start*** with and not repeat the code. *Therefore I am looking for some hints to start off*.

I prepared a mcve for you to see how it looks <https://jsfiddle.net/468bguu1/2/>

The formula is

Calculations ROW for month 1 is : `(.inc_row_0 + .inc_row_kor_0) - (.exp_row_0 + .exp_row_kor_0 + .work_row_0)`

For convenient calculations I added the classes names, I think thats how it should be done.

```
<table class="table table-striped table-bordered dataTable no-footer dtr-inline mt-5 table2excel">
          <thead class="btn-primary bg-primary">
            <tr>
              <th></th>
              <th>1</th>
              <th>2</th>
              <th>3</th>
              <th>4</th>
              <th>5</th>
              <th>6</th>
              <th>7</th>
              <th>8</th>
              <th>9</th>
              <th>10</th>
              <th>11</th>
              <th>12</th>
              <th></th>
            </tr>
          </thead>
          <tbody>
            <tr class="btn-primary bg-success">
              <td>ROW A Σ</td>
              <td class="inc_row_0">0,00</td>
              <td class="inc_row_1">0,00</td>
              <td class="inc_row_2">0,00</td>
              <td class="inc_row_3">0,00</td>
              <td class="inc_row_4">0,00</td>
              <td class="inc_row_5">0,00</td>
              <td class="inc_row_6">0,00</td>
              <td class="inc_row_7">103 091,99</td>
              <td class="inc_row_8">74 247,97</td>
              <td class="inc_row_9">42 660,39</td>
              <td class="inc_row_10">179 264,64</td>
              <td class="inc_row_11">9 693,49</td>
              <td></td>
            </tr>
            <tr class="btn-primary bg-success">
              <td>ROW A Adjust</td>
              <td class="inc_row_kor_0">0,00</td>
              <td class="inc_row_kor_1">0,00</td>
              <td class="inc_row_kor_2">0,00</td>
              <td class="inc_row_kor_3">0,00</td>
              <td class="inc_row_kor_4">0,00</td>
              <td class="inc_row_kor_5">0,00</td>
              <td class="inc_row_kor_6">0,00</td>
              <td class="inc_row_kor_7">0,00</td>
              <td class="inc_row_kor_8">0,00</td>
              <td class="inc_row_kor_9">0,00</td>
              <td class="inc_row_kor_10">0,00</td>
              <td class="inc_row_kor_11">0,00</td>
              <td></td>
            </tr>

            <tr class="btn-primary bg-danger">
              <td>ROW C</td>
              <td class="exp_row_0">0,00</td>
              <td class="exp_row_1">0,00</td>
              <td class="exp_row_2">0,00</td>
              <td class="exp_row_3">0,00</td>
              <td class="exp_row_4">0,00</td>
              <td class="exp_row_5">387,71</td>
              <td class="exp_row_6">387,71</td>
              <td class="exp_row_7">71 026,92</td>
              <td class="exp_row_8">43 914,10</td>
              <td class="exp_row_9">73 705,35</td>
              <td class="exp_row_10">77 213,29</td>
              <td class="exp_row_11">33,00</td>
              <td></td>
            </tr>

            <tr class="btn-primary bg-danger">
              <td>ROW C Adjust</td>
              <td class="exp_row_kor_0">0,00</td>
              <td class="exp_row_kor_1">0,00</td>
              <td class="exp_row_kor_2">0,00</td>
              <td class="exp_row_kor_3">0,00</td>
              <td class="exp_row_kor_4">0,00</td>
              <td class="exp_row_kor_5">0,00</td>
              <td class="exp_row_kor_6">0,00</td>
              <td class="exp_row_kor_7">0,00</td>
              <td class="exp_row_kor_8">0,00</td>
              <td class="exp_row_kor_9">0,00</td>
              <td class="exp_row_kor_10">0,00</td>
              <td class="exp_row_kor_11">0,00</td>
              <td></td>
            </tr>
            <tr></tr>
          </tbody>
          <tbody>
            <tr class="btn-primary bg-warning">
              <td>ROW D</td>
              <td class="work_row_0">0,00</td>
              <td class="work_row_1">0,00</td>
              <td class="work_row_2">0,00</td>
              <td class="work_row_3">0,00</td>
              <td class="work_row_4">0,00</td>
              <td class="work_row_5">0,00</td>
              <td class="work_row_6">0,00</td>
              <td class="work_row_7">30 788,44</td>
              <td class="work_row_8">27 522,85</td>
              <td class="work_row_9">25 827,27</td>
              <td class="work_row_10">22 443,28</td>
              <td class="work_row_11">-10 000,60</td>
              <td></td>
            </tr>
            <tr></tr>
          </tbody>

          <tbody>
            <tr class="btn-primary bg-primary">
              <td>Calculations ROW</td>
              <th class="res_row_0">x</th>
              <th class="res_row_1"></th>
              <th class="res_row_2"></th>
              <th class="res_row_3"></th>
              <th class="res_row_4"></th>
              <th class="res_row_5"></th>
              <th class="res_row_6"></th>
              <th class="res_row_7"></th>
              <th class="res_row_8"></th>
              <th class="res_row_9"></th>
              <th class="res_row_10"></th>
              <th class="res_row_11"></th>

            </tr>

          </tbody>
        </table>

```

My attempt : ( First have to normalize the text to a float )

```
     for (var i = 0; i < 12; i++) {
   var row_a = parseFloat($(".inc_row_" + i).text().replace(/ /g, '').replace(',', '.')) + parseFloat($(".inc_row_kor_" + i).text().replace(/ /g, '').replace(',', '.'));
   var row_b = parseFloat($(".exp_row_" + i).text().replace(/ /g, '').replace(',', '.')) + parseFloat($(".exp_row_kor_" + i).text().replace(/ /g, '').replace(',', '.')) + parseFloat($(".work_row_" + i).text().replace(/ /g, '').replace(',', '.'));
   var calc = row_a - row_b;

   $(".res_row_" + i).text(calc.toFixed(2));
 }

```