Hello,
I have this script wich works perfectly to create a PivotTable
async function main(workbook: ExcelScript.Workbook) {
try {let plageSource = workbook.getWorksheet("data").getRange("A1:D321");
let feuilleDest = workbook.addWorksheet("TableauCroiseDynamique");
let tableauCroiseDest = feuilleDest.getRange("A2");
let pivotTable = feuilleDest.addPivotTable("TableauCroiseDynamique", plageSource, tableauCroiseDest);
pivotTable.addRowHierarchy(pivotTable.getHierarchy("Chercheur"));pivotTable.addColumnHierarchy(pivotTable.getHierarchy("Typologie"));
pivotTable.addDataHierarchy(pivotTable.getHierarchy("NB"));pivotTable.addDataHierarchy(pivotTable.getHierarchy("%"))
} finally {}
}
The thing I want to do is to show this line " pivotTable.addDataHierarchy(pivotTable.getHierarchy("%")) " as a percentOfRowTotal like you can do it when you create your PivotTable manually.
ExcelScript seems to have this particular function " ExcelScript.ShowAsCalculation.percentOfRowTotal; " wich seems to be what I'm looking for but I don't know how to integrate it in my code.
Any Hints ?
Thanks a lot,
Loris