Difference of Row and % Difference of Row aggregations

Slice configuration

by Flexmonster Pivot Table

HTML

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

<div>
  <p>
    In this example, the <code>"differenceofrow"</code> and
    <code>"%differenceofrow"</code> aggregations are used to calculate a
    Difference of Row and a % Difference of Row of prices depending on a country
    and color.
  </p>
  <p>
    The <code>sum</code> aggregation is also used to demonstrate how the
    difference is calculated.
  </p>
  <p>
    Each cell shows either the difference or the percentage difference between
    two adjacent cells of the same level from left to right.<br />
    Cells in the first column are always empty because there are no adjacent
    cells before them.
  </p>
  <p>
    Read more about the
    <a
      target="_blank"
      href="https://www.flexmonster.com/doc/aggregation-functions/#difference-of-row"
      >"differenceofrow"</a
    >
    and
    <a
      target="_blank"
      href="https://www.flexmonster.com/doc/aggregation-functions/#percent-difference-of-row"
      >"%differenceofrow"</a
    >
    aggregations in Flexmonster docs.
  </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: "[Measures]"
      }],
      columns: [{
        uniqueName: "Color"
      }],
      measures: [{
        uniqueName: "Price",
        aggregation: "sum"
      }, {
        uniqueName: "Price",
        aggregation: "differenceofrow"
      }, {
        uniqueName: "Price",
        aggregation: "%differenceofrow"
      }]
    },
    formats: [{
      name: "",
      decimalSeparator: ".",
      decimalPlaces: 2,
      nullValue: "-"
    }]
  }
});