Skip to content

getCalculatedRange

This function allows you to call to another report, calculate it in the background without rendering it to the user and return the values from a given range.

Syntax

getCalculatedRange (reportname, range, asGrid, queryString, isPrivate, publisher)

Arguments

reportName

(Required)

The name of the report which you want to perform a background calculation on

range

(Required)

The range to return. This can be any of the following:

  • A1 reference
  • R1C1 reference
  • A1:B6 reference
  • Named range

asGrid

Whether the results should be returned in a grid style like they are layed out in Excel, or in a key/value pair object of cell reference and value.

Default value: false

queryString

Any additional query string arguments you want to pass in for the calculation of the report

Default value: ”“

isPrivate

Is this a private report

Default value: false

publisher

If it is a private report, specify the login id of the user that published it.

Default value: ”“

Return

If the asGrid option is not set or set to false, then the result set will be a JSON object in the following format

{ 
  "R1C1" : "A1",
  "R1C2" : "B1",
  "R2C1" : "A2",
  "R2C2" : "B2"
}

If the asGrid option is set to true, then the result set will be a JSON object in the following format:

{
  0 : [ "A1", "B1" ],
  1 : [ "A2", "B2" ]
}

Examples

The following code will call back to the server and calculate the named report and retrieve data from it, without ever rendering that report

//
// Example 1 - Calculate the named public report and retrieve range A1
//
var values1 = report.api.getCalculatedRange("MyTestReport", "A1");

//
// Example 2 - Calculate the named public report and retrieve range A1:B3
//
var values2 = report.api.getCalculatedRange("MyTestReport", "A1:B3");

//
// Example 3 - Calculate the named public report and retrieve range A1:B3 as a grid of data
//
var values3 = report.api.getCalculatedRange("MyTestReport", "A1:B3", true);

//
// Example 4 - Calculate the named public report with some query string parameters and
//             retrieve range A1:B3 as a grid of data.
//
var queryString = "[Date].[Date].%26[2]&R1C3=Yesterday"
var values4 = report.api.getCalculatedRange("MyTestReport", "A1:B3", true, queryString);

//
// Example 5 - Calculate the named private report and retrieve range A1:B3 as a grid of data
//
var values5 = report.api.getCalculatedRange("MyTestReport", "A1:B3", true, "", true, "sgibbs");