Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
 
Posts: n/a
Default add a column to a pivot table that would show the difference between 2 other Columns

Hello,
I would like to add a column to a pivot table that would show the
difference between the two other columns.

Below is a sample of data and the pivot table I can get to.

PrjType.........YR...........hrs
1...............2003............5
1...............2004............3
2...............2003............6
2...............2004............8
1...............2003............7
1...............2003............6
1...............2003............5
1...............2003............7


........................................____YR____ ___
ProjType......Data...................2003......... 2004
1.............Sum of hrs...............30...........3
...............Average of hrs2...........6...........3
2.............Sum of hrs............... 6...........8
...............Average of hrs2...........6...........8

What I would like is to add a column ("Diff") to the right, after
"2004" column to show the difference between 2004 and 2003-to
look like

.......................................___YR____
ProjType......Data...................2003.....2004 ......Diff
1.............Sum of hrs...............30.......3.........-27
................Average of hrs2.........6........3..........-3
2.............Sum of hrs............... 6.......8...........2
...............Average of hrs2..........6........8............2

Thanks

  #2   Report Post  
Ken Wright
 
Posts: n/a
Default

You have a couple of ways of handling this. First you can insert a
calculated item to handle this:-

With your table as you had it, drag the project type into the ROW fields,
the Year into the COLUMN fields, and the Hrs into the DATA field. Now click
on any of the years headings, ie 2003 or 2004, and then with the Pivot table
toolbar showing, click on Pivot Table / Formulas / Calculated item

On the dialog box that appears, replace the 'Formula1' with some logical
title such as 'Delta', and then with Year selected in the box on the left,
in the box where it says ' Formula = 0', delete the 0, double click the
2004, type - and then double click the 2003 such that the formula now looks
like = '2004'- '2003'. Now just hit OK and it will be added.

This works fine most of the time, but depending on how big your Pivot table
is, it may well bring it to it's knees. I use a laptop with a 1.7GHz
Centrino processor and 1GB of RAM. That is a lot of processing power, and
on some of my Pivot Tables (Which are admittedly huge), it often gets to a
point where it just cant handle putting this Delta in and crashes. I am
often dragging hundreds of thousands of rows of data though from Access as
my source. The workaround I use it to make all the data for say 2003
negative and then use the normal Row totals as my delta field which puts no
extra strain on the system at all. Very quick and simple to do, so if the
first way doesn't work for any reason then post back.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

wrote in message
oups.com...
Hello,
I would like to add a column to a pivot table that would show the
difference between the two other columns.

Below is a sample of data and the pivot table I can get to.

PrjType.........YR...........hrs
1...............2003............5
1...............2004............3
2...............2003............6
2...............2004............8
1...............2003............7
1...............2003............6
1...............2003............5
1...............2003............7


.......................................____YR_____ __
ProjType......Data...................2003......... 2004
1.............Sum of hrs...............30...........3
..............Average of hrs2...........6...........3
2.............Sum of hrs............... 6...........8
..............Average of hrs2...........6...........8

What I would like is to add a column ("Diff") to the right, after
"2004" column to show the difference between 2004 and 2003-to
look like

......................................___YR____
ProjType......Data...................2003.....2004 ......Diff
1.............Sum of hrs...............30.......3.........-27
...............Average of hrs2.........6........3..........-3
2.............Sum of hrs............... 6.......8...........2
..............Average of hrs2..........6........8............2

Thanks



  #3   Report Post  
Ken Wright
 
Posts: n/a
Default

Should have said - in the first method, you need to lose the Grand Totals
for the rows from the Table options, as they are nonsensical in this
context.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

"Ken Wright" wrote in message
...
You have a couple of ways of handling this. First you can insert a
calculated item to handle this:-

With your table as you had it, drag the project type into the ROW fields,
the Year into the COLUMN fields, and the Hrs into the DATA field. Now

click
on any of the years headings, ie 2003 or 2004, and then with the Pivot

table
toolbar showing, click on Pivot Table / Formulas / Calculated item

On the dialog box that appears, replace the 'Formula1' with some logical
title such as 'Delta', and then with Year selected in the box on the left,
in the box where it says ' Formula = 0', delete the 0, double click the
2004, type - and then double click the 2003 such that the formula now

looks
like = '2004'- '2003'. Now just hit OK and it will be added.

This works fine most of the time, but depending on how big your Pivot

table
is, it may well bring it to it's knees. I use a laptop with a 1.7GHz
Centrino processor and 1GB of RAM. That is a lot of processing power, and
on some of my Pivot Tables (Which are admittedly huge), it often gets to a
point where it just cant handle putting this Delta in and crashes. I am
often dragging hundreds of thousands of rows of data though from Access as
my source. The workaround I use it to make all the data for say 2003
negative and then use the normal Row totals as my delta field which puts

no
extra strain on the system at all. Very quick and simple to do, so if the
first way doesn't work for any reason then post back.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

--------------------------------------------------------------------------

--
It's easier to beg forgiveness than ask permission :-)
--------------------------------------------------------------------------

--

wrote in message
oups.com...
Hello,
I would like to add a column to a pivot table that would show the
difference between the two other columns.

Below is a sample of data and the pivot table I can get to.

PrjType.........YR...........hrs
1...............2003............5
1...............2004............3
2...............2003............6
2...............2004............8
1...............2003............7
1...............2003............6
1...............2003............5
1...............2003............7


.......................................____YR_____ __
ProjType......Data...................2003......... 2004
1.............Sum of hrs...............30...........3
..............Average of hrs2...........6...........3
2.............Sum of hrs............... 6...........8
..............Average of hrs2...........6...........8

What I would like is to add a column ("Diff") to the right, after
"2004" column to show the difference between 2004 and 2003-to
look like

......................................___YR____
ProjType......Data...................2003.....2004 ......Diff
1.............Sum of hrs...............30.......3.........-27
...............Average of hrs2.........6........3..........-3
2.............Sum of hrs............... 6.......8...........2
..............Average of hrs2..........6........8............2

Thanks





  #4   Report Post  
Max
 
Posts: n/a
Default

Tried tinkering around with the OP's pivot display replicated as a start
point earlier, viz,:

........................................____YR____ ___
ProjType......Data...................2003......... 2004
1.............Sum of hrs...............30...........3
...............Average of hrs2...........6...........3
2.............Sum of hrs............... 6...........8
...............Average of hrs2...........6...........8

Right-clicking on say: "2003" Formulas Calculated Items resulted in an
error msg: "Multiple data fields of the same field are not supported when a
Pivot Table has calculated items" So it looked like a dead-end there ..

Followed your schema, got it (the calculated items bit) up with SUM (only),
but it failed when I tried similarly with AVERAGE, throwing up the error
msg: "Averages, std deviations and variances are not supported when a Pivot
Table has calculated items"

Above experimented in Excel 97. Not sure whether the limitations above apply
to later versions though ..
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
Ken Wright wrote in message
...
Should have said - in the first method, you need to lose the Grand Totals
for the rows from the Table options, as they are nonsensical in this
context.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

--------------------------------------------------------------------------

--
It's easier to beg forgiveness than ask permission :-)
--------------------------------------------------------------------------

--

"Ken Wright" wrote in message
...
You have a couple of ways of handling this. First you can insert a
calculated item to handle this:-

With your table as you had it, drag the project type into the ROW

fields,
the Year into the COLUMN fields, and the Hrs into the DATA field. Now

click
on any of the years headings, ie 2003 or 2004, and then with the Pivot

table
toolbar showing, click on Pivot Table / Formulas / Calculated item

On the dialog box that appears, replace the 'Formula1' with some logical
title such as 'Delta', and then with Year selected in the box on the

left,
in the box where it says ' Formula = 0', delete the 0, double click the
2004, type - and then double click the 2003 such that the formula now

looks
like = '2004'- '2003'. Now just hit OK and it will be added.

This works fine most of the time, but depending on how big your Pivot

table
is, it may well bring it to it's knees. I use a laptop with a 1.7GHz
Centrino processor and 1GB of RAM. That is a lot of processing power,

and
on some of my Pivot Tables (Which are admittedly huge), it often gets to

a
point where it just cant handle putting this Delta in and crashes. I am
often dragging hundreds of thousands of rows of data though from Access

as
my source. The workaround I use it to make all the data for say 2003
negative and then use the normal Row totals as my delta field which puts

no
extra strain on the system at all. Very quick and simple to do, so if

the
first way doesn't work for any reason then post back.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03


--------------------------------------------------------------------------
--
It's easier to beg forgiveness than ask permission :-)


--------------------------------------------------------------------------
--

wrote in message
oups.com...
Hello,
I would like to add a column to a pivot table that would show the
difference between the two other columns.

Below is a sample of data and the pivot table I can get to.

PrjType.........YR...........hrs
1...............2003............5
1...............2004............3
2...............2003............6
2...............2004............8
1...............2003............7
1...............2003............6
1...............2003............5
1...............2003............7


.......................................____YR_____ __
ProjType......Data...................2003......... 2004
1.............Sum of hrs...............30...........3
..............Average of hrs2...........6...........3
2.............Sum of hrs............... 6...........8
..............Average of hrs2...........6...........8

What I would like is to add a column ("Diff") to the right, after
"2004" column to show the difference between 2004 and 2003-to
look like

......................................___YR____
ProjType......Data...................2003.....2004 ......Diff
1.............Sum of hrs...............30.......3.........-27
...............Average of hrs2.........6........3..........-3
2.............Sum of hrs............... 6.......8...........2
..............Average of hrs2..........6........8............2

Thanks







  #5   Report Post  
Ken Wright
 
Posts: n/a
Default

Hmmm - must admit I missed the bit with th two fields in there - Will take a
look and post back - Cheers for the catch Max.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

<snip




  #6   Report Post  
Ken Wright
 
Posts: n/a
Default

Good pickup Max, same in current versions. Plan B then in my book :-)

Autofilter your data and filter on just 2003. Put -1 in an empty cell and
copy the cell. Select all the visible data (numerics only) and do edit / Go
To / Special / Visible cells only, then do Edit / Paste Special / Multiply.
Now just refresh your table. Not ideal because one set of data is all
negative, but you can now use the Grand Totals for rows as your delta field.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

"Ken Wright" wrote in message
...
Hmmm - must admit I missed the bit with th two fields in there - Will take

a
look and post back - Cheers for the catch Max.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

--------------------------------------------------------------------------

--
It's easier to beg forgiveness than ask permission :-)
--------------------------------------------------------------------------

--

<snip




  #7   Report Post  
Max
 
Posts: n/a
Default

Ken Wright wrote
Good pickup Max, same in current versions. Plan B then in my book :-)

....
Thanks for the confirmation, Ken. At least I can rest easy on this <g
I'm gonna leave it to the OP to try your plan B ..

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----


  #8   Report Post  
Debra Dalgleish
 
Posts: n/a
Default

Add another copy of the Hours field to the data area
Right-click on the heading for the new field
Choose Field Settings
Type a name for the field, e.g. Change
Click the Options button
For 'Show Data as', choose 'Difference From'
As the Base Field, choose Year
As the Base Item, choose (previous)
Click OK

wrote:
Hello,
I would like to add a column to a pivot table that would show the
difference between the two other columns.

Below is a sample of data and the pivot table I can get to.

PrjType.........YR...........hrs
1...............2003............5
1...............2004............3
2...............2003............6
2...............2004............8
1...............2003............7
1...............2003............6
1...............2003............5
1...............2003............7


.......................................____YR_____ __
ProjType......Data...................2003......... 2004
1.............Sum of hrs...............30...........3
..............Average of hrs2...........6...........3
2.............Sum of hrs............... 6...........8
..............Average of hrs2...........6...........8

What I would like is to add a column ("Diff") to the right, after
"2004" column to show the difference between 2004 and 2003-to
look like

......................................___YR____
ProjType......Data...................2003.....2004 ......Diff
1.............Sum of hrs...............30.......3.........-27
...............Average of hrs2.........6........3..........-3
2.............Sum of hrs............... 6.......8...........2
..............Average of hrs2..........6........8............2

Thanks



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get pivot table data columns instead of rows Jessica Excel Discussion (Misc queries) 0 January 19th 05 04:29 PM
Pivot Table combining multiple columns Pete Petersen Excel Discussion (Misc queries) 1 January 13th 05 07:56 PM
pivot table row vs column headings mrs.champ Excel Worksheet Functions 1 January 12th 05 10:35 PM
ability to auto file column(s) on a pivot table km Excel Worksheet Functions 1 December 20th 04 09:39 PM
combining 3 columns of same info for a pivot table Julie Excel Worksheet Functions 0 December 15th 04 03:12 PM


All times are GMT +1. The time now is 07:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"