Pivotgrid custom expression
Hi i am looking for a small help creating simple PivotGrid from a Itemsource using custom calculation/expression. See Attached image.
Attachment: SimplePivotTableImg_3dccc955.rar
Attachment: SimplePivotTableImg_3dccc955.rar
SIGN IN To post a reply.
1 Reply
1 reply marked as answer
TB
Thirupathi Bala Krishnan
Syncfusion Team
May 13, 2021 12:14 PM UTC
Hi Gudmundur,
Thanks for contacting Syncfusion support.
We have analyzed your reported query “How to achieve the custom calculations in pivot grid”. We have prepared a simple sample based on your ItemSource value to display the pivot grid by using expression fields. You can follow any one of the methods to find out the differences of two calculations(Revenue and Expendure).
1.By using Expression Fields,
FieldInfo class is used to create the expression fields that are added to the AllowedFields collection of pivot grid control. This can be done either in XAML or code-behind.
Please refer the following code sample.
|
# MainWindow.xaml
<syncfusion:PivotGridControl x:Name="pivotGrid1" Margin="5" ShowGroupingBar="True"
ItemSource="{Binding PivotDataSourceData}">
<syncfusion:PivotGridControl.AllowedFields>
<syncfusion:FieldInfo Name="Difference" Expression="[Income] -[Expendure]"
FieldType="Expression" />
</syncfusion:PivotGridControl.AllowedFields>
<syncfusion:PivotGridControl.PivotRows>
<syncfusion:PivotItem FieldMappingName="Month" FieldHeader="Month" Format="MMM" TotalHeader="Total" />
</syncfusion:PivotGridControl.PivotRows>
<syncfusion:PivotGridControl.PivotCalculations>
<syncfusion:PivotComputationInfo CalculationName = "Total" Description = "Summation of values" FieldName = "Income" Format = "C" SummaryType="DoubleTotalSum"/>
<syncfusion:PivotComputationInfo CalculationName = "Total" Description = "Summation of values" FieldName = "Expendure" Format = "C" SummaryType="DoubleTotalSum"/>
<syncfusion:PivotComputationInfo CalculationName = "Total" Description = "Summation of values" FieldName = "Difference" Format = "# ##$" SummaryType="DoubleTotalSum"/>
</syncfusion:PivotGridControl.PivotCalculations>
</syncfusion:PivotGridControl>
|
For more details, please refer the following UG documentation,
https://help.syncfusion.com/wpf/pivot-grid/expression-fields
2.By using Calculated fields(Runtime),
https://help.syncfusion.com/wpf/pivot-grid/expression-fields
2.By using Calculated fields(Runtime),
- Open the calculated field window using the grouping bar context menu.
- Define the Name in the window.
- Formula can be entered by inserting calculation fields through the Fields section. For inserting numerical operator, you can use the formula pop-up.
- Click the Add button and then click OK button. Now pivot grid loaded with newly added calculated field.
- You can change the format value(adding currency) by using computation info dialog.
Please refer the attached videos from the following location:
For more details, please refer the following UG documentation,
Sample link: https://www.syncfusion.com/downloads/support/forum/165404/ze/PivotGridDemo1582491468
Please let us know if you need any further assistance.
Please let us know if you need any further assistance.
Regards,
Thirupathi B.
Marked as answer
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
- Marked answer
-
GG Gudmundur Gislason
- May 12, 2021 11:28 AM UTC
- May 13, 2021 12:14 PM UTC