Menu
Download Free Trial
  1. API reference
  2. Welcome
    1. Component overview
    2. Quickstart
    3. System requirements
    4. Troubleshooting
    5. Installation troubleshooting
    6. Managing license keys
  3. Connecting to Data Source
    1. JSON
      1. Connecting to JSON
      2. Data types in JSON
    2. CSV
      1. Connecting to CSV
      2. Connecting to CSV using Compressor
      3. Data types in CSV
    3. Database
      1. Connecting to SQL databases
      2. Connecting to other databases
      3. Connecting to database with .NET
      4. Connecting to database with .NET Core
      5. Connecting to database with Java
      6. Connecting to database with PHP
    4. Microsoft Analysis Services
      1. Connecting to Microsoft Analysis Services
      2. Getting started with Accelerator
      3. Installing Accelerator as a Windows Service
      4. Referring Accelerator as a DLL
      5. Configuring username/password protection
      6. Configuring secure HTTPS connection
      7. Troubleshooting
    5. Pentaho Mondrian
      1. Connecting to Pentaho Mondrian
      2. Getting started with Accelerator
      3. Configuring Mondrian roles
      4. Сonfiguring username/password protection
      5. Сonfiguring secure HTTPS connection
      6. Troubleshooting
    6. icCube
  4. Configuring report
    1. What is a report
    2. Data source
    3. Slice
    4. Options
    5. Number formatting
    6. Conditional formatting
    7. Set report to the component
    8. Get report from the component
    9. Date and time formatting
    10. Configuring global options
    11. Export and print
    12. Calculated values
    13. Custom sorting
  5. Integration with frameworks
    1. Available tutorials
    2. Integration with jQuery
    3. Integration with AngularJS
    4. Integration with Angular 2
    5. Integration with Angular 4
    6. Integration with React
    7. Integration with RequireJS
    8. Integration with TypeScript
    9. Integration with ASP.NET
    10. Integration with JSP
    11. Integration with PhoneGap
  6. Integration with charts
    1. Integration with Highcharts
    2. Integration with FusionCharts
    3. Integration with Google Charts
    4. Integration with any charting library
  7. Customizing
    1. Customizing toolbar
    2. Customizing appearance
    3. Localizing component
  8. Updating to the latest version
    1. Updating to the latest version
    2. Release notes
    3. Migration guide from 2.3 to 2.4
    4. Migration guide from 2.2 to 2.3
  9. Older Versions
    1. Documentation 2.3
    2. Documentation 2.2
    3. API reference - Flex
Table of contents

Calculated values

Calculated values provide you with the possibility to add some measures missing in the original data. They can be saved and restored within the report. This feature is available for JSON, CSV and OCSV data sources. Each calculated measure is described inside measure object. It can have the following parameters:

  • uniqueName – measure unique name, this property will be used as an identifier for the measure inside Pivot component and as the identifier to remove calculated measure via API.
  • caption (optional) – measure caption.
  • formula – string that represents the formula that can contain the following operations: +, -, *, /; the following operators:isNaN(), !isNaN(); other measures can be addressed using measure unique name and aggregation function, for example sum("Price") or max("Order"). Pivot supports the following aggregation functions for CSV, OCSV and JSON data sources: "sum", "count", "distinctcount", "average", "product", "min", "max", "percent", "percentofcolumn", "percentofrow", "index", "difference", "%difference".
  • grandTotalCaption (optional) – measure grand total caption.
  • active (optional) – boolean value that defines whether the calculated measure will be added to the list of available values but not selected (false) or will be selected for the report (true).
  • individual (optional) – Boolean. Defines whether the formula is calculated using raw values (true) or using aggregated values (false). Default value is false.
  • format (optional) – number formatting name.

This example on JSFiddle illustrates how to define calculated measure with the minimal price for each color. You should define slice the following way:

slice: {
	rows: [
		{ uniqueName: "Color" }
	],
	measures: [
		{ uniqueName: "Price", aggregation: "sum"},
		{
			formula: 'min("Price")',
			uniqueName: "Min Price",
			caption: "Min Price",
			active: true
		} 
	]
}

The next example illustrates how to define calculated measure with more complex formula. To highlight the values you can add conditional formatting for the Top Category measure:

slice: {
	rows: [
		{ uniqueName: "Color" }
	],
	measures: [
		{ uniqueName: "Price", aggregation: "sum"},
		{
			uniqueName: "Top Category",
			formula: 'average("Price") < 4000 and sum("Quantity") > 100',
			caption: "Top Category",
			active: true
		} 
	]
},
conditions: [
    {
        formula: "#value = 1",
        measure: "Top Category",
        format: {
            backgroundColor: "#66FF99",
            color: "#000000",
            fontFamily: "Arial",
            fontSize: "12px"
        }
    }
]

This JSFiddle shows how you can specify number format for your calculated measure.

individual property allows calculating the formula using raw values. In the example formula sum('Price') * sum('Amount') will be calculated as following:
set individual: true: 174 * 36 + 225 * 44
set individual: false: (174 + 225) * (36 + 44)

The following report illustrates how to use individual property:

{
	dataSource: {
		data: [
	        {
	            "Country" : "Canada",
	            "Amount" : 36,
	            "Price" : 174
	        },
	        {
	            "Country" : "Canada",
	            "Amount" : 44,
	            "Price" : 225
	        }
	    ]
	},
	slice: {
		rows: [
		    {
		        uniqueName: "Country"
		    }
		],
		measures: [
		    {
		        uniqueName: "Price",
		        aggregation: "sum",
		        active: true
		    },
		    {
		        uniqueName: "Overall price",
		        formula: "sum('Price') * sum('Amount')",
		        individual: true,
		        caption: "Overall price",
		        active: true
		    }
		]
	}
}

Add calculated values using Fields List

Please use Add calculated value in Fields List to add calculated measure in run time.

add calculated value

Сalculated values via API

Calculated measures can be defined within the report or added via addCalculatedMeasure(measure:Object) API call. To remove calculated measure use removeCalculatedMeasure(measureName:String). removeAllCalculatedMeasures() removes all calculated measures.