cancel
Showing results for 
Search instead for 
Did you mean: 

Sac scripting : filter attributes

0 Kudos

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

N1kh1l
Active Contributor
0 Kudos

rosanna.chiarazzo

Where is the attribute used ?

Do a console.log and see output of all the below variables and see if you are getting expected output

console.log(current_date );

console.log(date_new_millisec);

console.log(var start_date);

Nikhil

0 Kudos

i don't know how to read the attribute.

0 Kudos

i try with no success this code to retrive attributes; in table 2 I have exposed the attribute

var G_Selection = Table_2.getSelections();

console.log(["Selections",G_Selection]);

for(var i=1;i<99;i++){

var prop=Table_1.getDataSource().getResultMember("COMMESSA",G_Selection[i]).properties;

console.log(prop);};

Accepted Solutions (1)

Accepted Solutions (1)

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");

Answers (0)