Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
i have a requirement that,
in table i have a year field with 2011,2012,2013,2014
now using a variable i need grab the last two values even if another value is added to it
i.e, if we add 2015
i need to get 2014 and 2015
if we add another one 2016
i need to get 2015 and 2016
last two values i have to get.
I would suggest the following.
IN the script editor do the following resident load
Data:
LOAD * INLINE [
YearField
"2011,2012,2013,2014,2016"
];
We will assume the above is the data set for this example, from the above do a resident load
LOAD
YearField,
SubField(YearField,',') as FixedYearField
Resident Data;
It will create individual records for each year, and link back to the original text.
Now in the chart expression use the following:
Latest
Max(FixedYearField,1)
Second
Max(FixedYearField,2)
Just put the above in the variables you need
Reading replies I might have misunderstood your explanation of the year. If it is just a normal year field then the below will do the trick, just replace FixedYearField with your field
Latest
Max(FixedYearField,1)
Second
Max(FixedYearField,2)
Or use this. set a variable with the below code
='Max(FixedYearField,$1)'
And you can now use a single variable to call records like below, for this example the variable is called vtest.
Now to call the latest year, do
$(vtest(1))
Second latest
$(vtest(2))
Hi laxman,
Try this,