I have an Office Script that creates a Pivot Table. The last thing I would like to do is sort the pivot table on the same column values I filtered. Scripts doesn't record this action and I am not finding any examples. I do not understand how to format sortByValues.
// filter by value greater than $0
newPivotTable.getRowHierarchy("Vendor Name").getFields()[0].applyFilter({
valueFilter: {
condition: ExcelScript.ValueFilterCondition.greaterThan, /* Relationship */
comparator: 0, /* Value */
value: "Sum of Region Amt." /* The name of the data hierarchy.*/
}
});
// sort Vendor Name by "Sum of Region Amt." ascending
The code editor seems to accept newPivotTable.getRowHierarchy("Vendor Name").getPivotField("Vendor Name").sortByValues()
but I can't get the method of sortByValues to work. I can't format the three parameters correctly.