Add calculated measure - min

Calculated measures

by ilaria_nunziante

HTML

<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<button id="addNewData">
  Add new data
</button>
<button id="removeAddedData">
  Remove added data
</button>
<button id="addFormula">
  Add formula
</button>
<div id="pivot-container"></div>

JavaScript

$("#addNewData").click(function(e) {
  flexmonster.updateData({
    data: [{
      "Color": "green",
      "Country": "USA",
      "Price": 555,
      "Quantity": 26,
      "RowId": 4
    }]
  }, {
    partial: true
  });
});

$("#removeAddedData").click(function(e) {
  flexmonster.updateData({
    data: [{
      "Color": "green",
      "Country": "USA",
      "Price": 0,
      "Quantity": 0,
      "RowId": 4,
      "DeleteRow": true
    }]
  }, {
    partial: true
  });
});

$("#addFormula").click(function(e) {
  var formula = {
    formula: 'sum("Quantity")*sum("Price")',
    uniqueName: "QuantityTimesPrice",
    caption: "QuantityTimesPrice",
    grandTotalCaption: "QuantityTimesPrice",
    active: true
  };
  pivot.addCalculatedMeasure(formula);
});


var pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 430,
  toolbar: true,
  report: {
    dataSource: {
      data: getData()
    },
    slice: {
      rows: [{
          uniqueName: "Color"
        },
        {
          uniqueName: "[Measures]"
        },
      ],
      columns: [{
        uniqueName: "Country"
      }],
      measures: [{
          uniqueName: "Price",
          aggregation: "sum"
        },
        {
          uniqueName: "Quantity",
          aggregation: "sum"
        }
      ]
    }
  }
});

function getData() {
  return [{
    "Color": {
      "type": "string"
    },
    "Country": {
      "type": "string"
    },
    "Price": {
      "type": "number"
    },
    "Quantity": {
      "type": "number"
    },
    "RowId": {
      "type": "id"
    },
    "DeleteRow": {
      "type": "delete"
    }

  }, {
    "Color": "green",
    "Country": "Canada",
    "Price": 174,
    "Quantity": 22,
    "RowId": 1
  }, {
    "Color": "red",
    "Country": "USA",
    "Price": 1664,
    "Quantity": 19,
    "RowId": 2
  }, {
    "Color": "red",
    "Country": "Canada",
    "Price": 1190,
    "Quantity": 292,
    "RowId":...