Extract the last value from a Range Variable Value
By Cadence Analytics
var variable = chart_1.getDataSource().getVariables()[0];
var value = chart_1.getDataSource().getVariableValues(variable)[0];
var rangeValue = cast(Type.RangeVariableValue, value).to;
var filter_value=rangeValue.slice(4,7);
// apply the filterchart_2.getDataSource().setDimensionFilter("DIMENSION",filter_value);
Code language:JavaScript(javascript)
Step
What it does
Why it matters
getVariables()
Finds available prompts (variables) on the chart’s data source
So you know which variable you’re working with
getVariableValues()
Gets the current value(s) set for that variable
To read what the user or story has selected
cast(Type.RangeVariableValue, value)
Converts the value into a structured object with .from and .to
So you can access the start/end of a date or period range
.to
Gets the end of the selected range (e.g. 2025008)
You probably care about the latest period selected
slice(4,7)
Extracts the month part of a string like “2025008”