cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Image based filter for multiple charts with different data source in a page in SAP Analytics Cloud

sraji2486
Explorer
0 Likes
581

I am using the image-wise filter in SAP Analytics Cloud. Based on the scenario, provide the script code and specify where it should be written.

When I click the first image, the company code 1000 should be filtered. If I click the first image again, the filter for company code 1000 should be removed.

Next, if I click the second image, the company code 1200 should be filtered. If I click the first image while the second image is already clicked, both company codes 1000 and 1200 should be filtered. If I click the second image again, the filter for company code 1200 should be removed, leaving only the filter for company code 1000.

 

I have tried this below code, but it is applicable only if I clicked once, using script variable.

if(ScriptVariable_6 % 2 === 0){

                Chart_331.getDataSource().removeDimensionFilter("Company_Code");

                Chart_48.getDataSource().removeDimensionFilter("Company_Code");

                Chart_49.getDataSource().removeDimensionFilter("Company_Code");

                Chart_51.getDataSource().removeDimensionFilter("Company_Code");

                Chart_54.getDataSource().removeDimensionFilter("Company_Code");

                Chart_55.getDataSource().removeDimensionFilter("Company_Code");

                Chart_57.getDataSource().removeDimensionFilter("Company_Code");

                Chart_46.getDataSource().removeDimensionFilter("Company_Code");

                Chart_60.getDataSource().removeDimensionFilter("Company_Code");

                Chart_62.getDataSource().removeDimensionFilter("Company_Code");

                Chart_64.getDataSource().removeDimensionFilter("Company_Code");

                Chart_68.getDataSource().removeDimensionFilter("Company_Code");

                Chart_66.getDataSource().removeDimensionFilter("Company_Code");

                Chart_5.getDataSource().removeDimensionFilter("Company_Code");

                Chart_2.getDataSource().removeDimensionFilter("Company_Code");

                Chart_3.getDataSource().removeDimensionFilter("Company_Code");

                Chart_7.getDataSource().removeDimensionFilter("Company_Code");

    console.log(ScriptVariable_6);

}else

{

                 console.log(ScriptVariable_6);

                 Chart_331.getDataSource().setDimensionFilter("Company_Code",'1000');

                 Chart_48.getDataSource().setDimensionFilter("Company_Code",'1000');

                 Chart_49.getDataSource().setDimensionFilter("Company_Code",'1000');

                 Chart_51.getDataSource().setDimensionFilter("Company_Code",'1000');

                 Chart_54.getDataSource().setDimensionFilter("Company_Code",'1000');

                 Chart_55.getDataSource().setDimensionFilter("Company_Code",'1000');

                 Chart_57.getDataSource().setDimensionFilter("Company_Code",'1000');

                 Chart_46.getDataSource().setDimensionFilter("Company_Code",'1000');

                 Chart_60.getDataSource().setDimensionFilter("Company_Code",'1000');

                 Chart_62.getDataSource().setDimensionFilter("Company_Code",'1000');

                 Chart_64.getDataSource().setDimensionFilter("Company_Code",'1000');

                 Chart_68.getDataSource().setDimensionFilter("Company_Code",'1000');

                 Chart_66.getDataSource().setDimensionFilter("Company_Code",'1000');

                 Chart_5.getDataSource().setDimensionFilter("Company_Code",'1000');

                Chart_2.getDataSource().setDimensionFilter("Company_Code",'1000');

                Chart_3.getDataSource().setDimensionFilter("Company_Code",'1000');

                Chart_7.getDataSource().setDimensionFilter("Company_Code",'1000');

}

ScriptVariable_6 = ScriptVariable_6 + 1;

Accepted Solutions (0)

Answers (1)

Answers (1)

jain06
Explorer
0 Likes

Hi,

setdimensionfilter will overwrite existing filter. I have used 2 different script variables for 2 different images and define the cases (w.r.t variables).Check out the code below for Image 1 and same can be written for Image 2 as well.

 

if(ScriptVariable_1%2===0 && ScriptVariable_2%2!==0)   
{
Chart_1.getDataSource().setDimensionFilter("Product_3e315003an",["[Product_3e315003an].[Product_Catego_3o3x5e06y2].&[PC4]","[Product_3e315003an].[Product_Catego_3o3x5e06y2].&[PC1]"]);
}
else if(ScriptVariable_1%2===0 && ScriptVariable_2%2===0)----First time initialization
{
Chart_1.getDataSource().setDimensionFilter("Product_3e315003an","[Product_3e315003an].[Product_Catego_3o3x5e06y2].&[PC4]");
}
else if(ScriptVariable_2%2!==0)
{Chart_1.getDataSource().removeDimensionFilter("Product_3e315003an");
 Chart_1.getDataSource().setDimensionFilter("Product_3e315003an","[Product_3e315003an].[Product_Catego_3o3x5e06y2].&[PC1]");
}
 else
{
Chart_1.getDataSource().removeDimensionFilter("Product_3e315003an"); 
}
ScriptVariable_1=ScriptVariable_1+1;