# Calculated Fields in a Pivot Table when 'Fields' appear over Muliple Lines

1. ## Calculated Fields in a Pivot Table when 'Fields' appear over Muliple Lines

I have a Pivot Table where the 'Fields' appear over multiple lines, e.g. M1 Estimated Spend £000s appears as

M1
Estimated
Spend
£000s

I want to add some 'calculated fields' to give me specific totals and every thing I've tried to date just gives be an unhelpful message telling me there is an error in the formula. Basically if I wanted to say total the first three months estimated spend (see sample attached), I'd assumed this would work, but it doesn't

``Please Login or Register  to view this content.``
Note: There is a space both before M1, M2, M3 etc., and at the end of each line before the CHAR(10) line return apart from the last line where there is no space after £000s.

Is it me doing something wrong or is it simply not possible to achieve this when using line breaks in the field names?

2. ## Re: Calculated Fields in a Pivot Table when 'Fields' appear over Muliple Lines

I think the filename for your attachment may be too long. When I try to download it Windows tells me it can't find the file.

3. ## Re: Calculated Fields in a Pivot Table when 'Fields' appear over Muliple Lines

Hi HangMan,

As I've understood , you want to create sum of 3 following mounts (as stated in your formula M1, M2, M3), and to get the data from the pivot table.
To recreate the text "M1 Estimated Spend £000s", use the below formula.

= "M1" & " " & CHAR(10) & "Estimated" & " "& CHAR(10) & "Spend"& " " & CHAR(10) & "£000s"
Before CHAR(10) you have empty space.
Also, the text you need to have it in quotation marks.

To get value from pivot table, you need to use the "GETPIVOTDATA" function.

If you want to extract the total sum for the 3 month, use below formula:
=GETPIVOTDATA("M1" & " " & CHAR(10) & "Estimated" & " "& CHAR(10) & "Spend"& " " & CHAR(10) & "£000s",\$B\$3) + GETPIVOTDATA("M2" & " " & CHAR(10) & "Estimated" & " "& CHAR(10) & "Spend"& " " & CHAR(10) & "£000s",\$B\$3) + GETPIVOTDATA("M3" & " " & CHAR(10) & "Estimated" & " "& CHAR(10) & "Spend"& " " & CHAR(10) & "£000s",\$B\$3)

If you want to get the sum for particular area (e.g.: East), use the below formula:
=GETPIVOTDATA("M1" & " " & CHAR(10) & "Estimated" & " "& CHAR(10) & "Spend"& " " & CHAR(10) & "£000s",Pivot!\$B\$3,"Area","East") + GETPIVOTDATA("M2" & " " & CHAR(10) & "Estimated" & " "& CHAR(10) & "Spend"& " " & CHAR(10) & "£000s",Pivot!\$B\$3,"Area","East") + GETPIVOTDATA("M3" & " " & CHAR(10) & "Estimated" & " "& CHAR(10) & "Spend"& " " & CHAR(10) & "£000s",Pivot!\$B\$3,"Area","East")

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1