Running totals of Columns aggregation

Slice configuration

by Flexmonster Pivot Table

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<div>
  <p>
    In this example, the <code>"runningtotalsofcolumn"</code> aggregation is
    used to calculate running totals (cumulative sum) of prices depending on a
    country, category, and color.
  </p>
  <p>
    The <code>sum</code> aggregation is also used to demonstrate how the running
    totals are calculated.
  </p>
  <p>
    Note that the calculation is done separately for column cells of the same
    level from top to bottom.
  </p>
  <p>
    <a
      target="_blank"
      href="https://www.flexmonster.com/doc/aggregation-functions/#running-totals-of-columns"
      >Read more about the "runningtotalsofcolumn" aggregation in Flexmonster
      docs</a
    >.
  </p>
</div>

<div id="pivot-container"></div>

CSS

@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);

JavaScript

const pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  report: {
    dataSource: {
      filename: "data/data.csv"
    },
    slice: {
      rows: [{
        uniqueName: "Country"
      }, {
        uniqueName: "Category"
      }],
      columns: [{
        uniqueName: "Color"
      }, {
        uniqueName: "[Measures]"
      }],
      measures: [{
        uniqueName: "Price",
        aggregation: "sum"
      }, {
        uniqueName: "Price",
        aggregation: "runningtotalsofcolumn"
      }],
      expands: {
        expandAll: true
      }
    },
    formats: [{
      name: "",
      decimalSeparator: ".",
      decimalPlaces: 2,
      nullValue: "-"
    }]
  }
});