Skip to Content
0

Design Studio 1.6 excluding values from a dimension when the value is a variable

Jun 12, 2017 at 01:56 PM

409

avatar image

Hi there,

I have a question, is it possible to exclude values with .setFilter when the dimension and value are both variables?

Get the following error "Type "String" passed but "Boolean" expected for operator "!". Would somebody be kind enough to explain this?

Thanks in advance,

Ian.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Mustafa Bensan Jun 13, 2017 at 03:10 AM
1

Hi Ian,

Yes, it is possible but for exclusions you need to use setFilterExt() instead of setFilter(). Here's an example:

var myDim = "0WEEKDAY1";
var myVal = "!2";

DS_1.setFilterExt(myDim, myVal);

The syntax for exclusions is shown in the help text below:

Regards,

Mustafa.


filterexclusion.png (152.8 kB)
Share
10 |10000 characters needed characters left characters exceeded
Ian Mackay Jun 13, 2017 at 07:58 AM
0

Hi Mustafa,

Thanks for the response, unfortunately I think it's slightly more complex than I originally explained, maybe I can clarify slightly.

I have created a dynamic chart view using an SDK called Graphomate, Graphomate has built in software that can run a custom event from its context menu, based on the value that you select from the chart. However, Graphomate needs to know which dimension it needs to select the value you have clicked on from, because the chart is dynamic I need a script that retrieves the dimension currently active in the data source (and the chart which is connected to it).

The script below will add a filter to the DS_CHART based on what the user selects from the SDK chart view, I would like to allow them to be able to exclude a value using the same functionality but I'm not sure how as all of my variables are dynamic, where do I put the "!" in this script?

var Dim_Array_Rows = DS_CHART.getDimensions(Axis.ROWS);

var rows = "";

Dim_Array_Rows.forEach(function(element, index) {

 rows = element.name;

});

DS_CHART.setFilterExt(rows, P1_GRAPHOMATECHART_1.getSelectedMember(rows));

Thanks a lot for your help,

Ian.

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hi Ian,

Some more questions and comments to better understand your requirement:

1) Can you post a screenshot of an example chart?

2) When you say you have created a "dynamic chart view", do you mean that you have implemented functionality that manipulates the Row structure of DS_CHART based on a dimension selected by the user?

3) It appears that you are assuming there will only ever by one dimension in the row structure of the data source. If this is the case, there is no need to loop over Dim_Array_Rows. If the intent is to exclude the selected dimension member from the chart through filtering, your code should look something like this:

var Dim_Array_Rows = DS_CHART.getDimensions(Axis.ROWS);

var rowDimension = Dim_Array_Rows.pop(); // Get only dimension in array

var selectedMember = P1_GRAPHOMATECHART_1.getSelectedMember(rowDimension);

var filterValue = "!" + selectedMember.internalKey;

DS_CHART.setFilterExt(rowDimension, filterValue);

Let me know if you have any further questions or comments.

Regards,

Mustafa.

0

Hi Mustafa,

Actually I have 1 final question, your code above allows me to exclude 1 value from the current view, is there any further code I can add which allows me to exclude additional values? Unfortunately the setFilterExt function clears the filter before applying the new filter, is there any way around this? The perfect scenario would be that everytime this script is run it would simply add the additional value selected as an excluded value and leave any previous values still excluded.

Hope this makes sense, thanks very much for all your help.

Ian.

0

Actually, no worries Mustafa, I figured out how to do this myself

Again, thanks for all your help.

Ian.

0

Hi Mustafa,

I managed to get it to work based on your code, thanks very much for your help.

Ian.

1