on 2023 Jul 19 2:39 PM
Hi experts,
I am new to SAC scripting and I need assistance with filtering the date of my table dynamically based on 2 attributes of another dimension: Entity.
Each entity has a valid time written in two different attributes.
I have attempted the following script but i'm not able to retrive correct attributes.
var current_date = new Date(Date.now());
var date_new_millisec= current_date.setDate(current_date.getDate()
var start_date = new date ( date_new_millisec)
var range = TimeRange.create (TimeRangeGranularity.Month,start_date,current_date);
Table_1.getDataSource().setDimensionFilter ("Date",range);
Thanks a lot
I solved it: I insert the code maybe it can be useful to others.
console.log("COMMESSA-TEST ----------->");
var dimension1 = PlanningModel_1.getMembers("COMMESSA");
console.log(dimension1);
for(var i=0;i<dimension1.length;i++)
{
Dropdown_1.addItem(dimension1[i].id,dimension1[i].id);
};
console.log(dimension);
var sel = Dropdown_1.getSelectedText();
console.log(sel);
Table_1.getDataSource().setDimensionFilter ("COMMESSA",sel);
console.log("<-------------- COMMESSA-TEST");
console.log("TIME-TEST ----------->");
var dimension = PlanningModel_1.getMember("COMMESSA",sel);
var prop1 = dimension.properties["DATA_INI_EMISSIONE"];
var prop2 = dimension.properties["DATA_FINE_EMISSIONE"];
console.log(prop1);
console.log(prop2);
var yyyy = ConvertUtils.stringToInteger(prop1.substr(6,10));
var mm = ConvertUtils.stringToInteger(prop1.substr(3,5))-1;
var dd = ConvertUtils.stringToInteger(prop1.substr(0,2));
var pippo= new Date(yyyy,mm,dd);
console.log(yyyy);
console.log(mm);
console.log(dd);
console.log(pippo);
var yyyy1 = ConvertUtils.stringToInteger(prop2.substr(6,10));
var mm1 = ConvertUtils.stringToInteger(prop2.substr(3,5))-1;
var dd1 = ConvertUtils.stringToInteger(prop2.substr(0,2));
var pippo2= new Date(yyyy1,mm1,dd1);
var range = TimeRange.create (TimeRangeGranularity.Month,pippo,pippo2);
console.log(range);
Table_1.getDataSource().setDimensionFilter ("Date",range);
console.log("<-------------- TIME-TEST");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
69 | |
12 | |
11 | |
10 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.