% of Row and % of Parent Column Total aggregations

Slice configuration

by Flexmonster Pivot Table

HTML

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

<div>
  <p>
    In this example, the <code>"percentofrow"</code> and
    <code>"percentofparentcolumntotal"</code> aggregations are used to calculate
    a % of Row and a % of Parent Column Total of prices depending on a country,
    category and color.
  </p>
  <p>
    Each cell shows how much an individual value contributes either to the
    entire row total (<code>"percentofrow"</code>) or to the parent column total
    (<code>"percentofparentcolumntotal"</code>), expressed as a percentage.<br />
    Since the top level cells do not have parents, they contain the same values
    for both aggregations.
  </p>
  <p>
    Read more about the
    <a
      target="_blank"
      href="https://www.flexmonster.com/doc/aggregation-functions/#percent-of-row"
      >"percentofrow"</a
    >
    and
    <a
      target="_blank"
      href="https://www.flexmonster.com/doc/aggregation-functions/#percent-of-parent-column-total"
      >"percentofparentcolumntotal"</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: "Color"
      }, {
        uniqueName: "[Measures]"
      }],
      columns: [{
        uniqueName: "Country"
      }, {
        uniqueName: "Category"
      }],
      measures: [{
        uniqueName: "Price",
        aggregation: "percentofrow"
      }, {
        uniqueName: "Price",
        aggregation: "percentofparentcolumntotal"
      }],
      expands: {
        expandAll: true
      }
    },
    formats: [{
      name: "",
      decimalSeparator: ".",
      decimalPlaces: 2,
      nullValue: "-"
    }]
  }
});