-
Notifications
You must be signed in to change notification settings - Fork 63
/
excel.showasrule.yml
97 lines (86 loc) · 4.41 KB
/
excel.showasrule.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
### YamlMime:TSType
name: Excel.ShowAsRule
uid: 'excel!Excel.ShowAsRule:interface'
package: excel!
fullName: Excel.ShowAsRule
summary: ''
remarks: '\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
type: interface
properties:
- name: baseField
uid: 'excel!Excel.ShowAsRule#baseField:member'
package: excel!
fullName: baseField
summary: >-
The PivotField to base the `ShowAs` calculation on, if applicable according to the `ShowAsCalculation` type, else
`null`<!-- -->.
remarks: '\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'baseField?: Excel.PivotField;'
return:
type: '<xref uid="excel!Excel.PivotField:class" />'
- name: baseItem
uid: 'excel!Excel.ShowAsRule#baseItem:member'
package: excel!
fullName: baseItem
summary: >-
The item to base the `ShowAs` calculation on, if applicable according to the `ShowAsCalculation` type, else
`null`<!-- -->.
remarks: >-
\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-calculations.yaml
await Excel.run(async (context) => {
const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales");
const farmDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold at Farm");
const wholesaleDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold Wholesale");
farmDataHierarchy.load("showAs");
wholesaleDataHierarchy.load("showAs");
await context.sync();
// Show the difference between crate sales of the "A Farms" and the other farms.
// This difference is both aggregated and shown for individual fruit types (where applicable).
let farmShowAs = farmDataHierarchy.showAs;
farmShowAs.calculation = Excel.ShowAsCalculation.differenceFrom;
farmShowAs.baseField = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm");
farmShowAs.baseItem = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm").items.getItem("A Farms");
farmDataHierarchy.showAs = farmShowAs;
let wholesaleShowAs = wholesaleDataHierarchy.showAs;
wholesaleShowAs.calculation = Excel.ShowAsCalculation.differenceFrom;
wholesaleShowAs.baseField = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm");
wholesaleShowAs.baseItem = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm").items.getItem("A Farms");
wholesaleDataHierarchy.showAs = wholesaleShowAs;
await context.sync();
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'baseItem?: Excel.PivotItem;'
return:
type: '<xref uid="excel!Excel.PivotItem:class" />'
- name: calculation
uid: 'excel!Excel.ShowAsRule#calculation:member'
package: excel!
fullName: calculation
summary: The `ShowAs` calculation to use for the PivotField. See `Excel.ShowAsCalculation` for details.
remarks: '\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: >-
calculation: Excel.ShowAsCalculation | "Unknown" | "None" | "PercentOfGrandTotal" | "PercentOfRowTotal" |
"PercentOfColumnTotal" | "PercentOfParentRowTotal" | "PercentOfParentColumnTotal" | "PercentOfParentTotal" |
"PercentOf" | "RunningTotal" | "PercentRunningTotal" | "DifferenceFrom" | "PercentDifferenceFrom" |
"RankAscending" | "RankDecending" | "Index";
return:
type: >-
<xref uid="excel!Excel.ShowAsCalculation:enum" /> | "Unknown" | "None" | "PercentOfGrandTotal" |
"PercentOfRowTotal" | "PercentOfColumnTotal" | "PercentOfParentRowTotal" | "PercentOfParentColumnTotal" |
"PercentOfParentTotal" | "PercentOf" | "RunningTotal" | "PercentRunningTotal" | "DifferenceFrom" |
"PercentDifferenceFrom" | "RankAscending" | "RankDecending" | "Index"