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.
Script
// 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 dundas.data.RequestOverrides();
// Create measure sorting policy.
var measureSortingPolicy =
new dundas.data.MeasureSorting();
/*
var measureSortingPolicy = new dundas.data.MeasureSorting({
oppositeAxisMembers: 'EMEA.World Region'
});
*/
var measureSortingByHierarchyLevel =
new dundas.data.MeasureSortingByHierarchyLevel(
{
direction: measureSortDirectionOverride,
hierarchyUniqueName: 'Plant',
hierarchyLevelUniqueName: 'A.Plant',
// oppositeAxisMembers: 'EMEA.World Region'
});
var test = new dundas.data.MemberValue(
{
oppositeAxisMembers: 'EMEA.World Region',
hierarchyUniqueName: 'World Region',
levelUniqueName: 'World Region',
uniqueName: 'AMERICAS.World Region'
}
);
measureSortingPolicy.directions.push(measureSortingByHierarchyLevel);
measureSortingPolicy.oppositeAxisMembers.push(test);
var requestMeasureOverrides = new dundas.data.RequestMeasureOverrides(
{
uniqueName: 'One',
sortPolicy: measureSortingPolicy
});
requestOverrides.measureOverrides.push(requestMeasureOverrides);
var hierarchyOverride =
new dundas.data.RequestHierarchyOverrides(
{
uniqueName: 'Plant'
}
);
requestOverrides.hierarchyOverrides.push(hierarchyOverride);
// Get the metric set binging override.
var metricSetBindingOverride =
view.control.overrides.getMetricSetBindingOverrideById(chart1.id, chart1.metricSetBindings[0].id);
if(metricSetBindingOverride)
{
// Update the existing override.
metricSetBindingOverride.requestOverrides = requestOverrides;
}
else
{
// Add new override as one doesn't exist.
view.control.overrides.metricSetBindingOverrides.push(
{
adapterId: chart1.id,
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.