New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Total Formats

empty
ProfitCountryCity
TransportTypeCompany
empty
BulgariaBulgaria Total FranceFrance Total GreeceGreece Total HungaryHungary Total ItalyItaly Total RomaniaRomania Total SpainSpain Total UKUK TotalGrand Total
SofiaParisAthensKavalaSzegedBresciaArgesBucharestMadridBrandon
empty
MicrovanAdvanced Services Ace
Continential World Corp
Digital Corporate
Executive Imagination
Interactive Key Software
Internet Innovation Telecom
Networks Future Ll
Profit Interworks
Server Compu
Superior Outsourcing LLC
Grand Total
empty
$59,450.00$59,450.00$127,817.50$127,817.50$133,762.50$53,505.00$187,267.50$44,587.50$44,587.50$29,725.00$29,725.00$59,450.00$65,395.00$124,845.00$62,422.50$62,422.50$53,505.00$53,505.00$689,620.00
$65,395.00$65,395.00$154,570.00$154,570.00$101,065.00$62,422.50$163,487.50$65,395.00$65,395.00$32,697.50$32,697.50$44,587.50$47,560.00$92,147.50$65,395.00$65,395.00$32,697.50$32,697.50$671,785.00
$59,450.00$59,450.00$133,762.50$133,762.50$121,872.50$50,532.50$172,405.00$62,422.50$62,422.50$26,752.50$26,752.50$74,312.50$44,587.50$118,900.00$71,340.00$71,340.00$65,395.00$65,395.00$710,427.50
$59,450.00$59,450.00$104,037.50$104,037.50$95,120.00$62,422.50$157,542.50$56,477.50$56,477.50$56,477.50$56,477.50$59,450.00$71,340.00$130,790.00$56,477.50$56,477.50$50,532.50$50,532.50$671,785.00
$53,505.00$53,505.00$127,817.50$127,817.50$109,982.50$68,367.50$178,350.00$71,340.00$71,340.00$47,560.00$47,560.00$65,395.00$59,450.00$124,845.00$38,642.50$38,642.50$83,230.00$83,230.00$725,290.00
$68,367.50$68,367.50$104,037.50$104,037.50$118,900.00$62,422.50$181,322.50$50,532.50$50,532.50$89,175.00$89,175.00$50,532.50$53,505.00$104,037.50$59,450.00$59,450.00$44,587.50$44,587.50$701,510.00
$41,615.00$41,615.00$107,010.00$107,010.00$109,982.50$62,422.50$172,405.00$65,395.00$65,395.00$53,505.00$53,505.00$50,532.50$47,560.00$98,092.50$53,505.00$53,505.00$26,752.50$26,752.50$618,280.00
$35,670.00$35,670.00$86,202.50$86,202.50$92,147.50$38,642.50$130,790.00$62,422.50$62,422.50$56,477.50$56,477.50$62,422.50$29,725.00$92,147.50$65,395.00$65,395.00$71,340.00$71,340.00$600,445.00
$68,367.50$68,367.50$118,900.00$118,900.00$107,010.00$59,450.00$166,460.00$68,367.50$68,367.50$41,615.00$41,615.00$53,505.00$56,477.50$109,982.50$50,532.50$50,532.50$68,367.50$68,367.50$692,592.50
$59,450.00$59,450.00$107,010.00$107,010.00$104,037.50$53,505.00$157,542.50$50,532.50$50,532.50$65,395.00$65,395.00$50,532.50$38,642.50$89,175.00$50,532.50$50,532.50$56,477.50$56,477.50$636,115.00
$7,076,087.50$7,076,087.50$13,506,732.50$13,506,732.50$13,299,682.50$6,820,965.00$20,120,647.50$6,654,812.50$6,654,812.50$6,488,045.00$6,488,045.00$6,882,260.00$6,511,107.50$13,393,367.50$6,564,920.00$6,564,920.00$6,957,290.00$6,957,290.00$80,761,902.50
Page:
of 7Page size:
  • Demo Configurator
The current example demonstrates the different calculations RadPivotGrid can apply on your data. Instead of presenting the whole Total number you can show other information - for example, what percentage of the GrandTotal is the value in particular cell. Calculations are applied through the TotalFormat property collection exposed on the PivotGridAggregateField class. TotalFormat features the following properties:
  • TotalFunction – what type of calculation should be applied to the aggregate values
  • GroupName – if any, which group the calculations should be performed against. For example, the DifferenceFrom operation will calculate the difference between the current aggregate value and the aggregate value for the specified group.
  • Axis – which axis the calculations should be carried out against. For instance, the DifferenceFrom operation requires a group to be specified but this group can be present both on the Rows and Columns axis.
  • Level –sets which field to apply the calculation on - for example if you have three RowGroupFields, the first one will have level 0, second one - level 1 and the third one - level.
Let's go through a quick example: Say, we need to present all aggregate calculations as the difference between each aggregate value and the aggregate value that comes up for the Digital Corporate subgroup. Now, the Digital Corporate group is on level 1 at the Rows axis. The TotalFunction evidently should be set to the DifferenceFrom operator. Upon setting the controls accordingly in the config panel, just hit the Update button and see the result.
  • DefaultCS.aspx
  • DefaultCS.aspx.cs
<%@ Page Language="c#" AutoEventWireup="false" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.PivotGrid.Examples.TotalFormats.DefaultCS" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.QuickStart" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
   <div class="demo-container no-bg">
 <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadPivotGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadPivotGrid1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ConfiguratorPanel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ConfiguratorPanel1"></telerik:AjaxUpdatedControl>
                    <telerik:AjaxUpdatedControl ControlID="RadPivotGrid1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadPivotGrid RenderMode="Lightweight" runat="server" ID="RadPivotGrid1" AllowPaging="true" OnNeedDataSource="RadPivotGrid1_NeedDataSource"
        AllowSorting="true" AllowFiltering="false" ShowFilterHeaderZone="false">
        <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true"></PagerStyle>
        <Fields>
            <telerik:PivotGridRowField DataField="TransportType">
            </telerik:PivotGridRowField>
            <telerik:PivotGridRowField DataField="Company">
            </telerik:PivotGridRowField>
            <telerik:PivotGridColumnField DataField="Country">
            </telerik:PivotGridColumnField>
            <telerik:PivotGridColumnField DataField="City">
            </telerik:PivotGridColumnField>
            <telerik:PivotGridAggregateField DataField="Profit" Aggregate="Sum" DataFormatString="{0:C}">
            </telerik:PivotGridAggregateField>
            <telerik:PivotGridAggregateField IsHidden="true" DataField="Expenses" Aggregate="Sum">
            </telerik:PivotGridAggregateField>
        </Fields>
        <ClientSettings>
            <Scrolling AllowVerticalScroll="true"></Scrolling>
        </ClientSettings>
    </telerik:RadPivotGrid>
       </div>
    <telerik:ConfiguratorPanel runat="server" ID="ConfiguratorPanel1">
        <Views>
            <qsf:View>
                <qsf:ConfiguratorColumn runat="server" ID="ConfiguratorColumn1" Size="Medium">
                    <ul class="fb-group">
                        <li>
                            <qsf:ComboBox runat="server" Label="Total Function:" ID="rcmbTotalFunction" />
                        </li>
                        <li>
                            <qsf:TextBox ID="txtGroupName" Label="GroupName:" runat="server">
                            </qsf:TextBox>
                        </li>
                        <li>
                            <qsf:ComboBox runat="server" Label="Axis:" Size="Medium" ID="rcmbAxis">
                                <Items>
                                    <telerik:RadComboBoxItem Text="Rows" Value="Rows" Selected="true" />
                                    <telerik:RadComboBoxItem Text="Columns" Value="Columns" />
                                </Items>
                            </qsf:ComboBox>
                            <qsf:NumericTextBox ID="txtLevel" Label="Level:" Size="Medium" runat="server" Value="0">
                            </qsf:NumericTextBox>
                        </li>
                        <li>
                            <qsf:Button ID="btnUpdate" runat="server" Text="Update" />
                        </li>
                    </ul>
                </qsf:ConfiguratorColumn>
            </qsf:View>
        </Views>
    </telerik:ConfiguratorPanel>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance