Change Opposite Axis Member of Stacked Bar

Hello everybody!

I have a Stacked Bar as you can see in the image below. My Issue is that the sorting of the measure descending requires a specific ‘Opposite Axis Member’. In this Example I selected “EMEA”.

When I use a filter on the column and deselect ‘EMEA’ the sorting gets lost because ‘EMEA’ can no longer be the Opposite Axis Member.

I tried to solve it with this script but it doesn’t work.

// Determine the measure sort policy override.
var measureSortDirectionOverride = '';
measureSortDirectionOverride = dundas.SortDirection.DESCENDING;

// Get the canvas adapter;
var view = this.parentView;

// Create the request overrides object.
var requestOverrides = new;

// Create measure sorting policy.
var measureSortingPolicy = 

var measureSortingPolicy = new{
        oppositeAxisMembers: 'EMEA.World Region'

var measureSortingByHierarchyLevel = 
        direction: measureSortDirectionOverride,
        hierarchyUniqueName: 'Plant',
        hierarchyLevelUniqueName: 'A.Plant',
		// oppositeAxisMembers: 'EMEA.World Region'

var test = new
  oppositeAxisMembers: 'EMEA.World Region',
  hierarchyUniqueName: 'World Region', 
  levelUniqueName: 'World Region',
  uniqueName: 'AMERICAS.World Region'


var requestMeasureOverrides = new
    uniqueName: 'One',
    sortPolicy: measureSortingPolicy


var hierarchyOverride = 
               uniqueName: 'Plant'


// Get the metric set binging override.
var metricSetBindingOverride = 
    view.control.overrides.getMetricSetBindingOverrideById(, chart1.metricSetBindings[0].id);

  // Update the existing override.
  metricSetBindingOverride.requestOverrides = requestOverrides;
  // Add new override as one doesn't exist. 
      metricSetBindingId: chart1.metricSetBindings[0].id,
      requestOverrides: requestOverrides

// Refreshing Data.
`var dataLoadPromise = chart1.loadData();`

Template for Script

Is there someone who can help me with this issue or has another solution in mind?
Thanks in advance.

1 Like

Custom Sort, maybe. this works best if the list doesn’t get new items in it often.
You can set the order you want with a custom sort with out the Opposite Axis Member,

Not positive this will work but it what I would try next to see it it give the result you are wanting.

Thanks for the answer James. My chart works exactly as you suggested but the Issue occures when I filter on World Region and the initially selected Oppostite Axis Member is deselected the sorting gets lost. As you can see here I choosed ‘EMEA’ as Opposite Axis Member and then deselected it:

I want to change the Opposite Axis Member to on of the left item for example ‘AMERICAS’ in this example.

Hi Petros,

The script should work by re-sorting the measure, and it looks like it’s based on the example:

When you say it doesn’t work, which event/action did you use for the script? Have you tried it in the filter control’s parameter value changed action?

The above sample has a downloadable sample dashboard, does it work at all at your end?

What if you add a button, put the script into the button’s click action, and update the sort via the button?

Hello Jay,

What do you mean with re-sorting the measure? I guess my script contains incorrect code.

I used a button to run the script and also on the parameter value changed function of the filter but it didn’t work.

I imported the sample dashboard and it works without errors.

Hi Petros,

Can you please send an email to with a short description, and we can arrange a web meeting if it’s needed.

1 Like