This is a migrated thread and some comments may be shown as answers.

Possible cause on Calcualted Item null reference?

1 Answer 56 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 29 Jul 2014, 12:16 PM
Dear Telerik,

I'm trying to do an Year-On-Year comparison and I thought that creating a calculateditem will be the way of doing it (similar to this demo). However, I get the error of "Object reference not set to an instance of an object" I wonder what might be the potential cause?

Here's an extraction of the code I have and snapshot to show the grid structure.
<telerik:RadPivotGrid ID="RadPivotGrid_DataView" runat="server" Height="100%" AllowSorting="True" OnItemCommand="RadPivotGrid_DataView_ItemCommand" OnCellCreated="RadPivotGrid_DataView_CellCreated" DataSourceID="Sql_Contract_Details" EnableToolTips="True" EnableZoneContextMenu="True" EnableConfigurationPanel="True" OnFieldCreated="RadPivotGrid_DataView_FieldCreated" Skin="Office2010Blue" OnCellDataBound="RadPivotGrid_DataView_CellDataBound" Culture="en-GB" OnItemNeedCalculation="RadPivotGrid_DataView_ItemNeedCalculation" AllowPaging="True" PageSize="30" AggregatesLevel="1">
                                                <FieldsPopupSettings AggregateFieldsMinCount="1" />
                                                <PagerStyle ChangePageSizeButtonToolTip="Change Page Size" PageSizeControlType="RadComboBox" />
                                                <OlapSettings>
                                                    <XmlaConnectionSettings></XmlaConnectionSettings>
                                                </OlapSettings>
                                                <Fields>
                                                    <telerik:PivotGridReportFilterField Caption="Meeting Class" DataField="MeetingClass" UniqueName="MeetingClass" IsHidden="false">
                                                    </telerik:PivotGridReportFilterField>
                                                    <telerik:PivotGridReportFilterField Caption="Event Type" DataField="EventType" UniqueName="EventType" IsHidden="false">
                                                    </telerik:PivotGridReportFilterField>
                                                    <telerik:PivotGridReportFilterField Caption="M&E Cluster" DataField="M_and_E_Cluster" UniqueName="M_and_E_Cluster" IsHidden="false">
                                                    </telerik:PivotGridReportFilterField>
                                                    <telerik:PivotGridReportFilterField Caption="Source Group" DataField="LeadSource" UniqueName="LeadSource" IsHidden="false">
                                                    </telerik:PivotGridReportFilterField>
 
                                                    <telerik:PivotGridColumnField Caption="Creation Year" SortOrder="Descending" DataField="CreatedDate" GroupInterval="Year" UniqueName="CreationDateYear" IsHidden="false">
                                                        <%--THIS CAUSES "Object reference not set to an instance of an object" ERROR
                                                            <CalculatedItems>
                                                                <telerik:PivotGridCalculatedItem GroupName="Forecast for 1999"></telerik:PivotGridCalculatedItem>
                                                            </CalculatedItems>            
                                                        --%>                                       
                                                    </telerik:PivotGridColumnField>
                                                    <telerik:PivotGridRowField Caption="Creation Month" DataField="CreatedDate" GroupInterval="Month" UniqueName="CreationDateMonth" IsHidden="false">
                                                    </telerik:PivotGridRowField>
 
                                                    <telerik:PivotGridColumnField Caption="Arrival Year" SortOrder="Descending" DataField="EventStartDate" GroupInterval="Year" UniqueName="ArrivalYear" IsHidden="true">
                                                    </telerik:PivotGridColumnField>
                                                    <telerik:PivotGridRowField Caption="Arrival Month" DataField="EventStartDate" GroupInterval="Month" UniqueName="ArrivalMonth" IsHidden="true">
                                                    </telerik:PivotGridRowField>
 
                                                    <telerik:PivotGridRowField Caption="Status" DataField="StatusText" UniqueName="StatusText" IsHidden="false" SortOrder="None">
                                                        <CalculatedItems>
                                                            <telerik:PivotGridCalculatedItem GroupName="Total Exc TD"></telerik:PivotGridCalculatedItem>
                                                            <telerik:PivotGridCalculatedItem GroupName="Total"></telerik:PivotGridCalculatedItem>
                                                            <telerik:PivotGridCalculatedItem GroupName="Conversion % Exc TD"></telerik:PivotGridCalculatedItem>
                                                            <telerik:PivotGridCalculatedItem GroupName="Conversion %"></telerik:PivotGridCalculatedItem>
                                                        </CalculatedItems>
                                                    </telerik:PivotGridRowField>
 
                                                    <telerik:PivotGridAggregateField DataField="RecordCount" Aggregate="Count" Caption="Enquiries" IsHidden="false">
                                                    </telerik:PivotGridAggregateField>
                                                    <telerik:PivotGridAggregateField DataField="TotalFunctionRevenue" Aggregate="Sum" Caption="Revenue" IsHidden="false" DataFormatString="{0:C0}">
                                                    </telerik:PivotGridAggregateField>
                                                    <telerik:PivotGridAggregateField DataField="TotalFunctionRevenue" Aggregate="Average" Caption="Average Revenue" IsHidden="false" DataFormatString="{0:C0}">
                                                    </telerik:PivotGridAggregateField>
                                                    <telerik:PivotGridAggregateField DataField="RecordCount" Caption="YOY" IsHidden="false">
                                                        <TotalFormat Axis="Columns" TotalFunction="DifferenceFromPrevious" />
                                                    </telerik:PivotGridAggregateField>
                                                </Fields>
                                                <ClientSettings EnableFieldsDragDrop="True">
                                                    <Scrolling AllowVerticalScroll="True"></Scrolling>
                                                </ClientSettings>
                                                <TotalsSettings RowsSubTotalsPosition="None" RowGrandTotalsPosition="None" ColumnsSubTotalsPosition="None" ColumnGrandTotalsPosition="None"></TotalsSettings>
                                                <ConfigurationPanelSettings EnableOlapTreeViewLoadOnDemand="True" DefaultDeferedLayoutUpdate="True" LayoutType="OneByFour"></ConfigurationPanelSettings>
                                            </telerik:RadPivotGrid>


Many Thanks.

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 01 Aug 2014, 07:15 AM
Hi Tim,

Based in the information provided it would be hard to tell what exactly causes the problem. Could you please share with us the code-behind of the page as well so we could examine it?

Additionally I would like to ask you to explain in detail what is the targeted functionality. Maybe we can provide an alternative solution for it.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
PivotGrid
Asked by
Tim
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or