Running total issue

by ilaria_nunziante

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<button onclick="expandAll()">Expand all</button>
<button onclick="collapseAll()">Collapse all</button>
<div id="pivot-container"></div>

JavaScript

var data = [{
    "RowId": "1",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/01",
    "Quarter": "2023-Q1",
    "Semester": "2023-S1",
    "Year": "2023",
  },
  {
    "RowId": "2",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/02",
    "Quarter": "2023-Q1",
    "Semester": "2023-S1",
    "Year": "2023"
  },
  {
    "RowId": "3",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/03",
    "Quarter": "2023-Q1",
    "Semester": "2023-S1",
    "Year": "2023"
  },
  {
    "RowId": "4",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/04",
    "Quarter": "2023-Q2",
    "Semester": "2023-S1",
    "Year": "2023"
  },
  {
    "RowId": "5",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/05",
    "Quarter": "2023-Q2",
    "Semester": "2023-S1",
    "Year": "2023"
  },
  {
    "RowId": "6",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/06",
    "Quarter": "2023-Q2",
    "Semester": "2023-S1",
    "Year": "2023"
  },
  {
    "RowId": "7",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/07",
    "Quarter": "2023-Q3",
    "Semester": "2023-S2",
    "Year": "2023"
  },
  {
    "RowId": "8",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/08",
    "Quarter": "2023-Q3",
    "Semester": "2023-S2",
    "Year": "2023"
  },
  {
    "RowId": "9",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/09",
    "Quarter": "2023-Q3",
    "Semester": "2023-S2",
    "Year": "2023"
  },
  {
    "RowId": "10",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/10",
    "Quarter": "2023-Q4",
    "Semester": "2023-S2",
    "Year": "2023"
  },
  {
    "RowId": "11",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/11",
    "Quarter": "2023-Q4",
    "Semester": "2023-S2",
    "Year": "2023"
  },
  {
   ...