cancel
Showing results for 
Search instead for 
Did you mean: 

Remove dimension from chart using script code during execution

0 Kudos

Hi,

I have a data source with 2 dimensions and 1 measure

  1. Dimension1
  2. Dimension2
  3. Measure1

The need is to use this data source in 2 different charts of type pie.

1st pie chart will show Dimension1 and Measure1 (Dimension2 will not be there at all)

2nd pie chart will show Dimension2 and Measure1 (Dimension1 will not be there at all)

How can we achieve this during execution using script code?

Thank you,

Dimitris

former_member385171
Participant
0 Kudos

Hi Dimitris,

Did you tried to use below method for this.

DS.swapDimensions("Dim1",""Dim2");

Regards,

Swapnil

Accepted Solutions (1)

Accepted Solutions (1)

reiner_hille-doering
Active Contributor
0 Kudos

Nor really. The data selection API can be used to select existing data for your chart. It can't be used for anything that requires calculation. If you remove a dimension, it means in many cases that the numbers in existing data cells need to change - and this can't be done with data selection.

However there is usually a way to create two distinct charts from a single data source:

  1. Move the Measures dimension with the singel measure to Columns or to Free axis.
  2. Move Dimension1 to Columns and make sure that you have totals enabled.
  3. Move Dimension2 to Rows and make sure that you have totals enabled.
  4. For Chart1 make sure that is shows totals
  5. For Chart1 use data selection {"Dimension2": "(RESULT_MEMBER)"}
  6. For Chart2 make sure that is shows totals
  7. For Chart2 use data selection {"Dimension1": "(RESULT_MEMBER)"}

You might still be not happy with the shown charts, as the legends/axis contain something like "Total" or "Sum" - which you might not like. But generally it should work.

0 Kudos

Thank you for your answer.

I will try this and answer.

0 Kudos

The "Show Totals" = true changes the chart as we don't want to show totals in the chart but just the values that will produce the total

Can we use it with "Show Totals"= false?

Answers (3)

Answers (3)

reiner_hille-doering
Active Contributor
0 Kudos

If you set "Show Totals" = false, you probably don't see any data, as with the mentioned data selection JSONs, all members do contain total data (from the other, unwanted dimension).

reiner_hille-doering
Active Contributor
0 Kudos

You want to achieve it with chart.setDataSelection() API? This might be possible, depending if the resultset already contains all the data you want to show in the two charts.

First try it out in Designer using the the data selection UI. If it works, just pass the correct data selection JSON to setDataSelection API.

0 Kudos

Thank you for your answer.

As far as I know setDataSelection() works only for Measures and selected data

You cannot select a dimension out of many existing in the datasource in order to use just this in the chart without knowing the data that contains

0 Kudos

If I use this command then the other chart will change as well. This is something that I don't want.