I'm a newbie concering Office Script, maybe you could help me out.
I'm trying to apply Filters to a Pivot, but I'm getting the error: cannont read propertis of undefined (reading 'get fields')
I found out that i have forgotten to define something, but I don't know how to this in the code, here's my try:
function main(workbook: ExcelScript.Workbook) {
//Pivot definieren
let BasisFreiBlatt = workbook.getWorksheet("Basis FreiER");
const PivotFreiER = BasisFreiBlatt.getPivotTable("PivotFreiER");
//Filter Pivot
//Feld Frei ER auf nein
const freierField = PivotFreiER.getFilterHierarchy("frei ER");
getFields()[0];
freierField.applyFilter({
manualFilter: {
selectedItems: ["nein"] /* The included items. */
}
});
//Feld arch auf nein
const archField = PivotFreiER.getFilterHierarchy("arch").getFields()[0];
archField.applyFilter({
manualFilter: {
selectedItems: ["nein"] /* The included items. */
}
});
//Feld Ladetermin auf x
const ladeterminField = PivotFreiER.getFilterHierarchy("Ladetermin").getFields()[0];
ladeterminField.applyFilter({
manualFilter: {
selectedItems: ["x"] /* The included items. */
}
});
}
google search chat gpt foren
Pls try.