Specify different measures in the slice

Slice configuration

by Flexmonster Pivot Table

HTML

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

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

CSS

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

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  report: {
    dataSource: {
      filename: "data/data.csv"
    },
    slice: {
      rows: [{
        uniqueName: "Color"
      }],
      measures: [
        // A regular measure
        {
          uniqueName: "Price",
          active: true,
          aggregation: "sum",
          caption: "Price",
          format: "format 1",
          grandTotalCaption: "Total Price",
        },
        // A calculated value
        {
          uniqueName: "average_quantity",
          active: true,
          caption: "Average Quantity",
          formula: "sum('Quantity')/count('Quantity')",
          calculateNaN: true,
          format: "format 1",
          grandTotalCaption: "Average Quantity"
        }
      ]
    },
    formats: [{
      name: "format 1",
      decimalPlaces: 2,
    }],
  }
});