Calculated Members and Measures in UWP Pivot Client (SfPivotClient)

The SfPivotGrid allows users to add calculated measures and members in the OLAP report. There are two ways to define the calculated member or measure in the SfPivotClient as illustrated below.

Using calculated member editor dialog

The calculated member editor dialog can be opened by clicking the Create a Calculated Member/Measure icon available in the SfPivotClient’s toolbar. This icon will be visible only if the EnableCalculatedMembers property is enabled.

<pivotclient:SfPivotClient x:Name="PivotClient1" EnableCalculatedMembers="True" OlapDataManager="{Binding OlapDataManager}"/>
PivotClient1.EnableCalculatedMembers = true;
PivotClient1.EnableCalculatedMembers = True


Using OLAP report

You can define the calculated member or measure, and it can be added to any axis of the current OLAP report as specified in the following code snippet.

OlapReport olapReport = new OlapReport
    Name = "Calculated Report",
    CurrentCubeName = "Adventure Works"

DimensionElement dimensionElementColumn = new DimensionElement();
dimensionElementColumn.Name = "Customer";
dimensionElementColumn.HierarchyName = "Customer Geography";
dimensionElementColumn.AddLevel("Customer Geography", "Country");

MeasureElements measureElementColumn = new MeasureElements();
measureElementColumn.Elements.Add(new MeasureElement { Name = "Internet Sales Amount" });
measureElementColumn.Elements.Add(new MeasureElement { Name = "Sales Amount" });

DimensionElement dimensionElementRow = new DimensionElement();
dimensionElementRow.Name = "Date";
dimensionElementRow.AddLevel("Fiscal", "Fiscal Year");

// Calculated measure
CalculatedMember calculatedMeasure1 = new CalculatedMember();
calculatedMeasure1.Name = "Order on Discount Sale";
calculatedMeasure1.Expression = "[Measures].[Order Quantity] + ([Measures].[Order Quantity] * 0.10)";
calculatedMeasure1.AddElement(new MeasureElement { Name = "Order Quantity" });

// Adding column members

// Adding measure element

// Adding row members

Dim olapReport As New OlapReport() With { _
    Key .Name = "Calculated Report", _
    Key .CurrentCubeName = "Adventure Works" _

Dim dimensionElementColumn As New DimensionElement()
dimensionElementColumn.Name = "Customer"
dimensionElementColumn.HierarchyName = "Customer Geography"
dimensionElementColumn.AddLevel("Customer Geography", "Country")

Dim measureElementColumn As New MeasureElements()
measureElementColumn.Elements.Add(New MeasureElement() With { _
    Key .Name = "Internet Sales Amount" _
measureElementColumn.Elements.Add(New MeasureElement() With { _
    Key .Name = "Sales Amount" _

Dim dimensionElementRow As New DimensionElement()
dimensionElementRow.Name = "Date"
dimensionElementRow.AddLevel("Fiscal", "Fiscal Year")

' Calculated measure
Dim calculatedMeasure1 As New CalculatedMember()
calculatedMeasure1.Name = "Order on Discount Sale"
calculatedMeasure1.Expression = "[Measures].[Order Quantity] + ([Measures].[Order Quantity] * 0.10)"
calculatedMeasure1.AddElement(New MeasureElement() With { _
    Key .Name = "Order Quantity" _

' Adding column members

' Adding measure element

' Adding row members


A demo sample is available in the following location.

{system drive}:\Users\<User Name>\AppData\Local\Syncfusion\EssentialStudio\<Version Number>\Samples\UWP\SampleBrowser\PivotClient\PivotClient\View\CalculatedMembers.xaml