on 11-04-2015 1:17 PM
I need help with the Javascript to calculate the previous six months based on the current month. I tried using the While statement but that does not seem to be a valid statement in Design Studio. The data I am reading does not always have data for every month so I cannot use an array of the 0CALMONTH values. I want to do something like this (syntax is not correct just pseudo).
var month = APPLICATION.getInfo().dateNowInternalFormat.substring(4,2);
var year = APPLICATION.getInfo().dateNowInternalFormat.substring(0,4);
While (i < 6) {
month = month - 1;
if month > 1;
month = 12;
year = year - 1;
endif.
i++;
}
Thanks.
Sandy
This is what I eventually got to work. There is probably a better way to do this but I am a newbie to Javascript.
var current_month = APPLICATION.getInfo().dateNowInternalFormat;
var sCurrYear = APPLICATION.getInfo().dateNowInternalFormat.substring(0,4);
var iCurrYear = Convert.stringToInt(sCurrYear);
var sCurrMon = APPLICATION.getInfo().dateNowInternalFormat.substring(4,6);
var iCurrMon = Convert.stringToInt(sCurrMon);
var iRadioMonths = Convert.stringToInt(RADIOBUTTONGROUP_1.getSelectedValue());
if(iRadioMonths == 6 || iRadioMonths == 12){
var iMonths = iRadioMonths - 1;
var iMon = iCurrMon + iMonths * -1;
iCurrMon = iMon;
if(iMon<=0){
iCurrYear = iCurrYear - 1;
iCurrMon = iMon + 12;
}else{
if (iMon>12){
iCurrYear = iCurrYear +1;
iCurrMon = iMon - 12;
}
}
}
var iFrom = iCurrYear * 100;
iFrom = iFrom + iCurrMon;
var sFrom = Convert.floatToString(iFrom,"######");
DS_1.setFilter("0CALMONTH",{"low":sFrom,"high":current_month});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sandy - what is your data source? Wouldn't it be easier and faster to do this type of calculation in the BEx query (and by faster, I mean faster for your dashboard consumer of the Design Studio application)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.