APIs for Report
Overview
Details methods for api.report class.
api.report Class
Report definition for api class. Contains all report related API calls.
Methods
The following methods are applicable:
addLayoutField (gembarId formula gembarOrdinal)
Adds a single gem to the gembar via its formula. The gembarOrdinal allows one to set the location of of the inserted gem.
Parameters:
gembarId
(String)This is the id of the gembar. It depends on the visualization's type. For example, PIVOT allows values such as "rows", "columns", "measures".
formula
(String)This is the String representation of the formula to insert as a gem.
gembarOrdinal
(Number)This is the index at which to insert the gem. A value of -1 appends to the end of the list.
Example:
var gembarId = "rows"; var formula = "[Markets].[City]"; var gembarOrdinal = 1; api.report.addLayoutField( gembarId, formula, gembarOrdinal );
getFieldOption (formula name) String
Returns the field option's value by name for a given formula. For additional information, see APIs for Get/Set Field Options.
Parameters:
Returns:
- String
This is the option's value.
Example:
api.report.getFieldOption("[Markets].[Territory]", "showSubtotal");
getFilters ()
Returns:
-
JSON filters
This is a JSON object containing all non-numeric filters.
Example:
api.report.getFilters(); Return Value: {"filters": {"[Time].[Years]": [ {"operator": "EQUAL", "members": [ {"formula": "[Time].[2003]", "caption": "2003"}, {"formula": "[Time].[2004]", "caption": "2004"}, {"formula": "[Time].[2005]", "caption": "2005"} ]} ]}}
getLayoutFields (gembarId) Array
Returns the array of formulas for the layout fields by gembarId.
Parameters:
gembarId
(String)This is the id of the field. It depends on the visualization's type. For example, PIVOT allows values such as "rows", "columns", "measures".
Returns:
- Array
This is the array of formulas.
Example:
var gembarId = "rows"; api.report.getLayoutFields(gembarId); Return Value: ["[Markets].[Territory]"]
getName () String
Returns the name of the current report. New reports will return a null value.
Returns:
-
Name of the current report.
Example:
api.report.getName(); Return Value: "Country Performance (heat grid)"
getNumericFilters ()
Gets the numeric filters for the report. Note that a report may only have a single level with a numeric filter and that level must be displayed on the report. For additional information, see Analyzer Filters.
Returns:
-
All filters in a JSON object.
Example:
api.report.getNumericFilters(); Return Value: {"filters": {"[Markets].[Territory]": [ {"count": "10", "formula": "[Measures].[Sales]", "operator": "TOP"}, {"operator": "GREATER_THAN", "formula": "[Measures].[Sales]", "op1": "0.0"}, {"operator": "LESS_THAN", "formula": "[Measures].[Sales]", "op1": "100000000000"}, {"operator": "IS_NOT_EMPTY", "formula": "[Measures].[Sales]"} ]}}
removeFilters (level)
Removes all non-numeric filters for a given level.
Parameters:
level
(Object)This is the level on which the filter is being removed.
Example:
api.report.removeFilters("[Markets].[Territory]");
removeLayoutField (gembarId formula)
Removes a single gem from the gembar utilizing its formula as the key.
Parameters:
Example:
var gembarId = "rows"; var formula = "[Markets].[City]"; api.report.removeLayoutField(gembarId, formula);
removeNumericFilters ()
Removes all numeric filters on the report.
Example:
api.report.removeNumericFilters();
setFieldOption (formula name value)
Sets the field option's value by name for a given formula. For additional information, see APIs for Get/Set Field Options.
Parameters:
Example:
api.report.setFieldOption("[Markets].[Territory]", "label", "My Territory");
setFilters (level filterItems)
Sets non-numeric filters on a level removing all previous non-numeric filters. For additional information, see Analyzer Filters.
Parameters:
Example:
api.report.setFilters("[Time].[Years]" , [ { // Builds a relative equal filter for Previous, Current, and Next on Years "operator": "EQUAL", "members": [-1, 0, 1] }, { // Builds an exact equal filter on Years "operator": "EQUAL", "members": [ { "formula": "[Time].[2003]", "caption": "2003" }, { "formula": "[Time].[2004]", "caption": "2004" }, { "formula": "[Time].[2005]", "caption": "2005" }] }, { "operator": "TIME_RANGE_PREV", "members": [10] }, { "operator": "TIME_RANGE_NEXT", "members": [10] }, { "operator": "TIME_AGO", "members": [10] }, { "operator": "TIME_AHEAD", "members": [10] }, { "operator": "BETWEEN", "members": [ {"formula": "[Time].[2003]", "caption": "2003"}, {"formula": "[Time].[2005]","caption": "2005"}] }]); api.report.setFilters("[Markets].[Territory]" , [{ "operator": "CONTAIN", "members": ["APAC"] }]);
setLayoutFields (gembarId formulas)
Sets the array of formulas for the layout fields by gembarId. It overwrites the existing fields in the current gembar. Each formula is validated. If the formula is invalid, then it will not be set.
Parameters:
Example:
var gembarId = "rows"; var formulas = [ "[Markets].[Territory]", "[Markets].[Country]" ]; api.report.setLayoutFields(gembarId, formulas);
setNumericFilters (level filter)
Sets a numeric filter on a level. There can only be one numeric filter per report. This method will remove any pre-existing numeric filter on the report. For additional information, see Analyzer Filters.
Parameters:
Example:
api.report.setNumericFilters("[Markets].[Territory]", [{"count": "10", "formula": "[Measures].[Sales]", "operator": "TOP"}, {"operator": "GREATER_THAN", "formula": "[Measures].[Sales]", "op1": "0.0"}, {"operator": "LESS_THAN", "formula": "[Measures].[Sales]", "op1": "100000000000"}, {"operator": "IS_NOT_EMPTY", "formula": "[Measures].[Sales]"}]);
setVizId (vizId)
Sets the report visualization using the visualization id.
Parameters:
vizId
(String)This is the id of the visualization.
Example:
api.report.setVizId("ccc_bar");