I would like to change the sort direction of a row in a table using script. I don't even know where to begin as I've done a lot of searching, but haven't found what I need.
Thanks,
Matt
I would like to change the sort direction of a row in a table using script. I don't even know where to begin as I've done a lot of searching, but haven't found what I need.
Thanks,
Matt
Hello Matt,
A good place to start would be the script sample Setting View and Metric Set Overrides. Let me know if you have difficulty working through this sample.
Alternatively (and when possible, recommended), you can use the UI to perform the sorting. Please take a look at the article sorting a table visualization for the various sorting options available. For example, using the Sort dialog or by setting up One Click Sorting.
Please let me know if you have any questions about this.
Regards,
Larsen
Hi Larsen,
I have the following scrip to sort a measure from a table/chart.
The thing is that in my table, there are two hierarchies (shown in a flat table).
Any idea on how can I adapt this script for it to work on my two hierarchy table?
Thanks!
var myView=window.dundas.context.baseViewService.currentView;
var myChart=myView.getAdapters().toEnumerable().first(function(a){
//Replace your script chart name
return name==="chart1";
});
//Create an array of metric set binding information to override it
var override={
adapterId: myChart.id,
metricSetBindingId: myChart.metricSetBindings[0].id,
requestOverrides: new dundas.data.RequestOverrides()
};
var metricSetOverrides = myView.control.overrides;
//Create Directions object
var measureSortDirections = new dundas.data.MeasureSortingByHierarchyLevel({
direction:"Ascending",
//Replace on your Hierarchy names
hierarchyUniqueName:"ProductID",
hierarchyLevelUniqueName:"ProductID"
});
var sortPolicy=new dundas.data.MeasureSorting({
directions:[measureSortDirections],
oppositeAxisMembers:[]
});
var requestOverride=new dundas.data.RequestMeasureOverrides({
//Replace on your measure name
uniqueName:"LineTotal",
sortPolicy:sortPolicy
});
override.requestOverrides.measureOverrides.push(requestOverride);
metricSetOverrides.metricSetBindingOverrides.push(override);
myChart.loadData();
metricSetOverrides.metricSetBindingOverrides=[];
Hello Octavian,
Would you be able to provide me with your use case so I can provide you a suitable solution?
Hi Larsen,
Of course, we can speak in private about the usecase, cause it can't pe public, then we can post here the script explaining what is does, if that's ok.
Thanks!!
That sounds great, I will follow up with you via email!