ExcelScript.PivotManualFilter interface
Configurable template for a manual filter to apply to a PivotField. The condition
defines what criteria need to be set in order for the filter to operate.
Remarks
Examples
/**
* This script adds a manual filter to a PivotTable.
*/
function main(workbook: ExcelScript.Workbook)
{
// Get the first PivotTable in the workbook.
const pivot = workbook.getPivotTables()[0];
// Get the hierarchy to use as the filter.
const location = pivot.getHierarchy("Location");
// Use "Location" as the FilterHierarchy.
pivot.addFilterHierarchy(location);
// Select items for the filter.
const cityFilter: ExcelScript.PivotManualFilter = {
selectedItems: ["Seattle", "Chicago"]
};
// Apply the filter
// Note that hierarchies and fields have a 1:1 relationship in Excel, so `getFields()[0]` always gets the correct field.
location.getFields()[0].applyFilter({
manualFilter: cityFilter
});
}
Properties
selected |
A list of selected items to manually filter. These must be existing and valid items from the chosen field. |
Property Details
selectedItems
A list of selected items to manually filter. These must be existing and valid items from the chosen field.
selectedItems?: (string | PivotItem)[];
Property Value
(string | ExcelScript.PivotItem)[]
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Office Scripts