Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

Wiki Markup
{introducedin: 8.4

...

Description

Excerpt

Sets the ShowValueAs properties of a PivotTable.

Signature
C#C#
}
{description}
{excerpt}
Sets the {{ShowValueAs}} properties of a PivotTable.
{excerpt}
{signature:C#}
public SetShowValueAs(PivotTableField.ShowValueAsType showValueAs, SourceField baseField, Int32 baseItemIndex)
Signature
{signature}
{signature:vb.net
vb.net
}
public Function SetShowValueAs(ByVal showValueAs As ShowValueAs.ShowValueAsType, ByVal baseField As SourceField, ByVal baseItemIndex As Integer)
Parameters
{signature}

{parameters}
{param:showValueAs}
The type of ShowValueAs described by ShowValueAsType.
{param}
{param:baseField}
The base field for comparisons.
{param}
{param:baseItemIndex}
The index of the base item for comparisons
{param}

{example}
{code:csharp|title=C#}
ExcelApplication xla = new ExcelApplication();
          Workbook wb = xla.Open(@"C:\MySpreadsheet.xlsx");
          Worksheet ws = wb.Worksheets[0];
          PivotTable pt = ws.PivotTables[0];
          DataField df = pt.DataFields[0];
          df.SetShowValueAs(ShowValueAs.ShowValueAsType.Difference, pt.SourceFields[0], 0);
{code}
{code:vb.net
|title=vb.net
}
Dim xla As New ExcelApplication()
          Dim wb As Workbook = xla.Open("C:\MySpreadsheet.xlsx")
          Dim ws As Worksheet = wb.Worksheets(0)
          Dim pt As PivotTable = ws.PivotTables(0);
          Dim df As DataField = pt.DataFields(0)
          df.SetShowValueAs(ShowValueAs.ShowValueAsType.Difference, pt.SourceFields(0), 0);
Param
showValueAsshowValueAs

The type of ShowValueAs described by ShowValueAsType.

Param
baseFieldbaseField

The base field for comparisons.

Param
baseItemIndexbaseItemIndex

The index of the base item for comparisons

Example
Code Block
csharpcsharp
titleC#
Code Block
vb.nettitle
Remarks

This property cannot be set on ValuesLabels. You can check if a PivotField is calculated field with the IsValuesLabel Property

This is the same as going to Value Field Settings > Show values as.

When calling SetShowValueAs(), certain ShowValueAsTypes use a source field as a base field and an index for one of the values in the data source column associated with the source field. The base field and value specified by the base item index are used to compute the values shown in the PivotTable.

Use ShowValueAs.BaseItemNext and ShowValueAs.BaseItemPrevious to specify Next or Previous.
{code}

{example}

{remarks}This property cannot be set on ValuesLabels. You can check if a PivotField is calculated field with the [IsValuesLabel |EW8:PivotTableField.IsValuesLabel]Property

This is the same as going to _Value Field Settings_ > _Show values as_.

When calling {{[SetShowValueAs()|ShowValueAs.SetShowValueAs (ShowValueAsType, SourceField, Int32)]}}, certain {{ShowValueAsTypes}} use a source field as a base field and an index for one of the values in the data source column associated with the source field. The base field and value specified by the base item index are used to compute the values shown in the PivotTable.

Use {{[ShowValueAs.BaseItemNext]}} and {{[ShowValueAs.BaseItemPrevious]}} to specify _Next_ or _Previous_.
{remarks}