Using getVariablesValues API
The new API getVariableValues() returns an array of the current values of the specified variable:
getVariableValues( variable: string | VariableInfo ) : VariableValue[]
var values = Table_1.getDataSource().getVariableValues("V_Country"); // 'values' is an array of VariableValue objects
Each value in the array is an instance of either SingleVariableValue, MultipleVariableValue or RangeVariableValue, which all inherit from VariableValue. To work with such an instance (which means access its type-specific properties), it needs to be cast to the corresponding type first, using the type property. Please see the following section
var value = Table_1.getDataSource().getVariableValues("V_Country")[0]; switch (value.type) { case VariableValueType.Single: var singleValue = cast(Type.SingleVariableValue, value); console.log(singleValue.value); // can access the 'value' property now break; case VariableValueType.Multiple: var multiValue = cast(Type.MultipleVariableValue, value); console.log(multiValue.values); // can access the 'values' property now break; case VariableValueType.Range: var rangeValue = cast(Type.RangeVariableValue, value); console.log(rangeValue.from); // can access the 'from' property now console.log(rangeValue.to); // can access the 'to' property now // further range properties: 'less', 'lessOrEqual', 'greater', 'greaterOrEqual' break; default: break; }
Table_1.getDataSource().setVariableValue("V_Country", { values: [ "DE", "FR" ], exclude: true }); Table_1.getDataSource().setVariableValue("V_Country", [ { value: "DE", exclude: true }, { value: "FR", exclude: true } ]);
[ { values: [ "DE", "FR" ], exclude: true } ]
Synchronization in the other direction is not performed by getVariableValues. Thus, the API will still return the same variable value, even though the user might have modified the filter in the meantime. To retrieve the current value of such special variables, use getDimensionFilters() instead (or likewise, getHierarchy() for hierarchy variables).