Running total without hierarchy

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",
    "Year": "2023"
  },
  {
    "RowId": "2",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/02",
    "Quarter": "2023-Q1",
    "Year": "2023"
  },
  {
    "RowId": "3",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/03",
    "Quarter": "2023-Q1",
    "Year": "2023"
  },
  {
    "RowId": "4",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2023/04",
    "Quarter": "2023-Q2",
    "Year": "2023"
  },
  {
    "RowId": "4",
    "Product": "Product 1",
    "Quantity": 1,
    "Month": "2024/01",
    "Quarter": "2024-Q1",
    "Year": "2024"
  }
];

var pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 430,
  report: {
    "dataSource": {
      "type": "json",
      "data": data,
      "mapping": {
        "RowId": {
          "type": "id"
        },
        "Product": {
          "type": "string"
        },
        "Month": {
          "type": "string"
        },
        "Quarter": {
          "type": "string"
        },
        "Year": {
          "type": "string"
        },
        "Quantity": {
          "type": "number"
        }
      }
    },
    "slice": {
      "rows": [{
        "uniqueName": "Product",
      }, {
        "uniqueName": "[Measures]"
      }],
      "columns": [{ 
        "uniqueName": "Year",
        "sort": "asc"
      },{
        "uniqueName": "Quarter",
        "sort": "asc"
      },{
        "uniqueName": "Month",
        "sort": "asc"
      }],
      "measures": [{
          "uniqueName": "Quantity"
        },
        {
          "formula": "runningtotalsofrow('Quantity')",
          "uniqueName": "Runnging total",
        }
      ],
      "expands": {
        "expandAll": true
     ...