SAC: Filter Multiple Dimension with One Input Field

Estimated read time 8 min read

Hello All,

In this blog, I wanted to show how you can filter multiple dimensions with one input parameter. The classical filtering works as adding filters for each dimension on report but with this effective way, you need only one input parameter and you can filter whole different dimensions individually with this input field.
the gif that below down shows how it works. There are three different dimensions on table and when I input a value and push the filter button, it filters the dimension that has contains my input so, no need to write whole data inside. Also there is no case sensitivity.

For example when I write an input as “Turk” , it detect that this input is contained in “Country” dimension as “Turkey” and then it filters country. When I write “Eur” it filters “Region” dimension at this time and also same for “soda” filters “Product Group” dimension.
The scripting is not working on dimensions with their name, it works with dimensions order. Therefore when I add a new dimension, it works for it too. I added three loops into the scripting so, it works for only first three dimensions. You can add loops as much as you want.

How to do it? (for only multiple filtering)
-Necessary Widgets: Table, Input Field , Button (* I filtered only table in this example you can add other widgets too as you wish)
-Scripting (You have to add scripting to only Button)

 

var INPUTTAKI_DEGER = InputField_1.getValue().toLowerCase();
//get the value from input field into global variable

var BOYUT1 = Table_1.getDimensionsOnRows()[0];
var BOYUT2 = Table_1.getDimensionsOnRows()[1];
var BOYUT3 = Table_1.getDimensionsOnRows()[2];
//get dimensions that you want to filter into local variables. for this case I used three dimensions. You can use more or less but if you will use more, you have to script more loops for every dimension.

Table_1.getDataSource().removeDimensionFilter(BOYUT1);
Table_1.getDataSource().removeDimensionFilter(BOYUT2);
Table_1.getDataSource().removeDimensionFilter(BOYUT3);
// remove filters on dimensions. Also you can add a new “remove filters” button and use the scripting part up to here to remove all filters.

if (INPUTTAKI_DEGER.length===0 )
{return;}
//If there is no value inside input field, scripting will stop here and all filters will be deleted on these first 3 dimensions.

//First Loop
var SECILENLER = Table_1.getDataSource().getDataSelections();
for (var i=0;i<SECILENLER.length;i++)
{var Uyeler = Table_1.getDataSource().getResultMember(BOYUT1,SECILENLER[i]);
var buyuk_kucuk_harf_esiteleme = Uyeler.description.toLowerCase();
// With this for loop, every member in that dimension will be in variable “UYELER”. last part gets the first dimension’s descriptions into a variable “buyuk_kucuk_harf_esiteleme” as lowercase.

var ESAS_UYE = Uyeler.description;
// ESAS_UYE variable will take the Original description value.

if(buyuk_kucuk_harf_esiteleme.includes(INPUTTAKI_DEGER))
// this if condition checks if the input value is contained in a value from first dimension. if there is, condition will be applied. If there is not, it will goes to second loop

{ Table_1.getDataSource().setDimensionFilter(BOYUT1,ESAS_UYE);
console.log(ESAS_UYE);
return ;}}
// if the value in input is contained in first dimension, it filters table and stop scripting here. if it doesn’t stop, this will work anyway but gives an error and works for nothing.

//second Loop
var SECILENLER2 = Table_1.getDataSource().getDataSelections();
for (var a=0;a<SECILENLER2.length;a++)
{var Uyeler2 = Table_1.getDataSource().getResultMember(BOYUT2,SECILENLER[a]);
var buyuk_kucuk_harf_esiteleme2 = Uyeler2.id.toLowerCase();

var ESAS_UYE2 = Uyeler2.id;
//I used ID here, for my case ids and descriptions are same but you can use necessary one in your case. id is better generally if you can choose it.

if(buyuk_kucuk_harf_esiteleme2.includes(INPUTTAKI_DEGER))

{Table_1.getDataSource().setDimensionFilter(BOYUT2,ESAS_UYE2);
console.log(ESAS_UYE2);
return ;}}
console.log(INPUTTAKI_DEGER);

//third Loop
var SECILENLER3 = Table_1.getDataSource().getDataSelections();
for (var e=0;e<SECILENLER3.length;e++)
{var Uyeler3 = Table_1.getDataSource().getResultMember(BOYUT3,SECILENLER[e]);
var buyuk_kucuk_harf_esiteleme3 = Uyeler3.id.toLowerCase();

var ESAS_UYE3 = Uyeler3.id;

if(buyuk_kucuk_harf_esiteleme3.includes(INPUTTAKI_DEGER))

{Table_1.getDataSource().setDimensionFilter(BOYUT3,ESAS_UYE3);
console.log(ESAS_UYE3);
return;}}

 

 

Summary

In this work,  I aimed to show you how to filter multiple dimension. With this way user can manage every dimensions with only one input field. 

When I was looking for analytic application examples, I saw a great blog from  @JBARLOW  and I wanted to add something on it. Therefore I got inspired from his work “Use a text search to filter a dashboard”. Thanks. 

 

​ Hello All,In this blog, I wanted to show how you can filter multiple dimensions with one input parameter. The classical filtering works as adding filters for each dimension on report but with this effective way, you need only one input parameter and you can filter whole different dimensions individually with this input field.the gif that below down shows how it works. There are three different dimensions on table and when I input a value and push the filter button, it filters the dimension that has contains my input so, no need to write whole data inside. Also there is no case sensitivity.For example when I write an input as “Turk” , it detect that this input is contained in “Country” dimension as “Turkey” and then it filters country. When I write “Eur” it filters “Region” dimension at this time and also same for “soda” filters “Product Group” dimension.The scripting is not working on dimensions with their name, it works with dimensions order. Therefore when I add a new dimension, it works for it too. I added three loops into the scripting so, it works for only first three dimensions. You can add loops as much as you want.How to do it? (for only multiple filtering)-Necessary Widgets: Table, Input Field , Button (* I filtered only table in this example you can add other widgets too as you wish)-Scripting (You have to add scripting to only Button) var INPUTTAKI_DEGER = InputField_1.getValue().toLowerCase();
//get the value from input field into global variable

var BOYUT1 = Table_1.getDimensionsOnRows()[0];
var BOYUT2 = Table_1.getDimensionsOnRows()[1];
var BOYUT3 = Table_1.getDimensionsOnRows()[2];
//get dimensions that you want to filter into local variables. for this case I used three dimensions. You can use more or less but if you will use more, you have to script more loops for every dimension.

Table_1.getDataSource().removeDimensionFilter(BOYUT1);
Table_1.getDataSource().removeDimensionFilter(BOYUT2);
Table_1.getDataSource().removeDimensionFilter(BOYUT3);
// remove filters on dimensions. Also you can add a new “remove filters” button and use the scripting part up to here to remove all filters.

if (INPUTTAKI_DEGER.length===0 )
{return;}
//If there is no value inside input field, scripting will stop here and all filters will be deleted on these first 3 dimensions.

//First Loop
var SECILENLER = Table_1.getDataSource().getDataSelections();
for (var i=0;i<SECILENLER.length;i++)
{var Uyeler = Table_1.getDataSource().getResultMember(BOYUT1,SECILENLER[i]);
var buyuk_kucuk_harf_esiteleme = Uyeler.description.toLowerCase();
// With this for loop, every member in that dimension will be in variable “UYELER”. last part gets the first dimension’s descriptions into a variable “buyuk_kucuk_harf_esiteleme” as lowercase.

var ESAS_UYE = Uyeler.description;
// ESAS_UYE variable will take the Original description value.

if(buyuk_kucuk_harf_esiteleme.includes(INPUTTAKI_DEGER))
// this if condition checks if the input value is contained in a value from first dimension. if there is, condition will be applied. If there is not, it will goes to second loop

{ Table_1.getDataSource().setDimensionFilter(BOYUT1,ESAS_UYE);
console.log(ESAS_UYE);
return ;}}
// if the value in input is contained in first dimension, it filters table and stop scripting here. if it doesn’t stop, this will work anyway but gives an error and works for nothing.

//second Loop
var SECILENLER2 = Table_1.getDataSource().getDataSelections();
for (var a=0;a<SECILENLER2.length;a++)
{var Uyeler2 = Table_1.getDataSource().getResultMember(BOYUT2,SECILENLER[a]);
var buyuk_kucuk_harf_esiteleme2 = Uyeler2.id.toLowerCase();

var ESAS_UYE2 = Uyeler2.id;
//I used ID here, for my case ids and descriptions are same but you can use necessary one in your case. id is better generally if you can choose it.

if(buyuk_kucuk_harf_esiteleme2.includes(INPUTTAKI_DEGER))

{Table_1.getDataSource().setDimensionFilter(BOYUT2,ESAS_UYE2);
console.log(ESAS_UYE2);
return ;}}
console.log(INPUTTAKI_DEGER);

//third Loop
var SECILENLER3 = Table_1.getDataSource().getDataSelections();
for (var e=0;e<SECILENLER3.length;e++)
{var Uyeler3 = Table_1.getDataSource().getResultMember(BOYUT3,SECILENLER[e]);
var buyuk_kucuk_harf_esiteleme3 = Uyeler3.id.toLowerCase();

var ESAS_UYE3 = Uyeler3.id;

if(buyuk_kucuk_harf_esiteleme3.includes(INPUTTAKI_DEGER))

{Table_1.getDataSource().setDimensionFilter(BOYUT3,ESAS_UYE3);
console.log(ESAS_UYE3);
return;}}
  SummaryIn this work,  I aimed to show you how to filter multiple dimension. With this way user can manage every dimensions with only one input field. When I was looking for analytic application examples, I saw a great blog from  @JBARLOW  and I wanted to add something on it. Therefore I got inspired from his work “Use a text search to filter a dashboard”. Thanks.    Read More Technology Blogs by Members articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author

+ There are no comments

Add yours