Get and Set Field Options APIs
This set of APIs allows for the manipulation of the user fields in Analyzer. Depending on the field type, different options are available. As these options are turned on and off, the values will be reflected in the in the right-click context menu for the appropriate field.
How to Call these API's
There are two functions for editing field options, getFieldOption
and setFieldOption
. Get returns the value of the option specified in the call. Method signatures are below:
cv.api.report.getFieldOption(formula:string, name:string);
To set an option on a field, the level or formula that contains the field is passed into the setFieldOption
method along with the field name and the value to set as below:
cv.api.report.setFieldOption(formula:string, name:string, value:string);
To make sure changes are reflected in the report, the refreshReport
method needs to be called.
cv.api.operation.refreshReport();
These are the field options that are available for Analyzer.
label
This option allows the user to set the string label for a field. This option is available for measures and attributes.
Example
cv.api.report.setFieldOption("[Markets].[Territory]", "label", "SAMPLE_LABEL_TITLE");
The current value of label for a field can be retrieved using the getFieldOption
method. If the label is not specified the function returns null.
Example
var labelValue = cv.api.report.getFieldOption("[Markets].[Territory]", "label");
sortOrderEnum
This option allows the user to set the sort order to ascending or descending as well as remove the sort order for a field. The following are acceptable string values values for the value parameter:
NONE - remove sort order
ASC - set ascending order
DESC - set descending order
This option is available for measures and attributes.
Example
cv.api.report.setFieldOption("[Markets].[Territory]", "sortOrderEnum", "ASC");
The current value of sortOrderEnum
for a field can be retrieved using the getFieldOption
method. This function returns one of acceptable values: NONE, ASC, DESC.
Example
var sortOrderValue = cv.api.report.getFieldOption("[Markets].[Territory]", "sortOrderEnum");
showAggregate
This option allows the user to show or hide the aggregate value panel. There are two acceptable strings for the value parameter, true and false. This option is available only for measures.
Example
cv.api.report.setFieldOption("[Measures].[Sales]", "showAggregate", "true");
The current value of showAggregate
for a field can be retrieved using the getFieldOption
method. This function returns either true or false.
Example
var showAggregate = cv.api.report.getFieldOption("[Measures].[Sales]", "showAggregate");
showSum
This option allows the user to show or hide the sum value panel. There are two acceptable strings for the value parameter, true and false. This option is available only for measures.
Example
cv.api.report.setFieldOption("[Measures].[Sales]", "showSum", "true");
The current value of showSum
for a field can be retrieved using the getFieldOption
method. This function returns either true or false based on whether the panel is visible or not.
Example
var showSum = cv.api.report.getFieldOption("[Measures].[Sales]", "showSum");
showAverage
This option allows the user to show or hide the average value panel. There are two acceptable strings for the value parameter, true and false. This option is available only for measures.
Example
cv.api.report.setFieldOption("[Measures].[Sales]", "showAverage", "true");
The current value of showAverage
for a field can be retrieved using the getFieldOption
method. This function returns either true or false based on whether the panel is visible or not.
Example
var showAverage = cv.api.report.getFieldOption("[Measures].[Sales]", "showAverage");
showMin
This option allows the user to show or hide the minimum value panel. There are two acceptable strings for the value parameter, true and false. This option is available only for measures.
Example
cv.api.report.setFieldOption("[Measures].[Sales]", "showMin", "true");
The current value of showMin
for a field can be retrieved using the getFieldOption
method. This function returns either true or false based on whether the panel is visible or not.
Example
var showMin = cv.api.report.getFieldOption("[Measures].[Sales]", "showMin");
showMax
This option allows the user to show or hide the max value panel. There are two acceptable strings for the value parameter, true and false. This option is available only for measures.
Example
cv.api.report.setFieldOption("[Measures].[Sales]", "showMax", "true");
The current value of showMax
for a field can be retrieved using the getFieldOption
method. This function returns either true or false based on whether the panel is visible or not.
Example
var showMax = cv.api.report.getFieldOption("[Measures].[Sales]", "showMax");
showSubtotal
This option allows the user to show or hide the subtotal panel. There are two acceptable strings for the value parameter, true and false. This option is available only for measures.
Example
cv.api.report.setFieldOption("[Markets].[Territory]", "showSubtotal", "true");
The current value of showSubtotal
for a field can be retrieved using the getFieldOption
method. This function returns either true or false based on whether the panel is visible or not.
Example
var subTotal = cv.api.report.getFieldOption("[Markets].[Territory]", "showSubtotal");
formatShortcut
This option allows the user to define conditional formatting on a measure. The value parameter can be set to one of the following options:
NONE - remove all color formatting.
COLOR_SCALE_G_Y_R - green, yellow and red gradients are applied from maximum value to minimum value.
COLOR_SCALE_R_Y_G - red, yellow and green gradients are applied from maximum value to minimum value.
COLOR_SCALE_B_Y_R - blue, yellow and red gradients are applied from maximum value to minimum value.
COLOR_SCALE_R_Y_B - red, yellow and blue gradients are applied from maximum value to minimum value.
TREND_ARROW_GR - gradient for green arrow.
TREND_ARROW_RG - gradient for red arrow.
DATA_BAR_RED - red gradient for bar scale.
DATA_BAR_GREEN - green gradient for bar scale.
DATA_BAR_BLUE - blue gradient for bar scale.
Example
cv.api.report.setFieldOption("[Measures].[Sales]", "formatShortcut", "DATA_BAR_BLUE");
The current value of formatShortcut
for a field can be retrieved using the getFieldOptions
method. This function returns the shortcut color gradient as a string.
Example
var format = cv.api.report.getFieldOption("[Measures].[Sales]", "formatShortcut");
formatCategory
This option allows the user to define category formatting on a measure. The following strings are acceptable for the the value parameter: Default, General Number, Currency ($), Percentage (%), Expression.
Example
cv.api.report.setFieldOption("[Measures].[Sales]", "formatCategory", "Percentage (%)");
The current value of formatCategory
for a field can be retrieved using the getFieldOption
method. This function returns the category as a string.
Example
var category = cv.api.report.getFieldOption("[Measures].[Sales]", "formatCategory")
formatScale
This option allows the user to set the number of decimal digits used in a measure. The parameter value can have one of the following string values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. The user can see this result with any formatCategory
except for Expression, since it is not a numeric value.
Example
cv.api.report.setFieldOption("[Measures].[Sales]", "formatScale", "3");
The current value of formatScale
for a field can be retrieved using the getFieldOption
method. This function returns the scale as a string.
Example
var scale = cv.api.report.getFieldOption("[Measures].[Sales]", "formatScale");
formatExpression
This option allows the user to define an MDX expression for formatting a measure. This can only be used with the formatCategory
set to Expression. The value parameter must be a string representation of a valid MDX expression.
Example
cv.api.report.setFieldOption("[Measures].[Sales]", "formatExpression", "Case When [Measures].CurrentMember > 0 Then '~~#,##0~~' Else '|#,##0' End");
The current value of formatExpression
for a field can be retrieved using the getFieldOptions
method. This function returns the MDX expression as a string.
Example
cv.api.report.getFieldOption("[Measures].[Sales]", "formatExpression");
currencySymbol
This option allows the user to set the currency symbol for a measure. This symbol is displayed with the value of a measure. The value parameter can be any string value. This option only works with formatCategory = “Currency ($)”
.
Example
cv.api.report.setFieldOption("[Measures].[Sales]", "currencySymbol", "!!!");
The current value of currencySymbol
for a field can be retrieved using the getFieldOption
method. This function returns the currency symbol as a string.
Example
cv.api.report.getFieldOption("[Measures].[Sales]", "currencySymbol");
Last updated
Was this helpful?