27
Calc Guide Chapter 8 Using Pivot Tables

PivotTables Tutorial

Embed Size (px)

DESCRIPTION

Free

Citation preview

Page 1: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 1/26

Calc Guide

Chapter 8

Using Pivot Tables

Page 2: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 2/26

Copyright

This document is Copyright © 2009–2012 by its contributors as listed below. You may distribute itand/or modiy it under the terms o the Creati!e Commons "ttribution#$hare "li%e &icense'http(//creati!ecommons.org/licenses/by#sa/).0/*+ !ersion ).0 or later.

"ll trademar%s within this guide belong to their legitimate owners.

Authors

,arbara -upreyartin oean ollis 3eberohn " $mith

Feedback4lease direct any comments or suggestions about this document to(documentation5global.libreoice.org

Acknowledgments

This chapter is based on and updated rom Chapter 6 o the OpenOffice.org 3.3 Calc Guide+ which was adapted rom a German original written by $tean 3eigel and translated into 7nglish by $igrid8ronenberger. ther contributors to that chapter are(

ean ollis 3eber "ndy ,rown $haron 3histonClaire 3ood artin o

Publication date and software version

4ublished 1: uly 2012. ,ased on &ibreice ).;.<.

Note for Mac users

$ome %eystro%es and menu items are dierent on a ac rom those used in 3indows and &inu.The table below gi!es some common substitutions or the instructions in this chapter. or a moredetailed list+ see the application elp.

Windows or Linux Mac equivalent Effect  

Tools > ptions menuselection

!ibreffice > Preferences "ccess setup options

Right-click Controlclick   pens a contet menu

Ctrl !Control"   z 'Co##and * =sed with other %eys

$% &hift  >z>$% pens the ?a!igator

$''   z>T  pens the $tyles and ormatting window

(ocu#entation for )ibreOffice is available at  http*++,,,.libreoffice.org+get-help+docu#entation

Page 3: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 3/26

Contents

Copyright"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" #

Note for Mac users"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""#

$mportant note"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" %

$ntroduction"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" %

-atabase preconditions............................................................................................................... ;

-ata sources................................................................................................................................@Calc spreadsheet.................................................................................................................... @Aegistered data source........................................................................................................... @

Creating a 4i!ot Table.................................................................................................................. <

The &ataPilot dialog"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""'

,asic layout................................................................................................................................. <

ore options................................................................................................................................ 6

ore settings or the ields( ield options................................................................................... 10ptions or -ata ields..........................................................................................................10ptions or Aow and Column ields...................................................................................... 12ptions or 4age ields......................................................................................................... 1@

(orking with the results of the &ataPilot )the Pivot Table*"""""""""""""""""""""""""""""""""""""""""""+,

Changing the layout................................................................................................................... 1@

Grouping rows or columns......................................................................................................... 1@

Grouping o categories with scalar !alues..................................................................................1<

Grouping without automatic creation o inter!als....................................................................... 1:

$orting the result........................................................................................................................ 16

$elect sort order rom drop#down menus on each column heading.......................................16$ort manually by using drag and drop................................................................................... 19$ort automatically.................................................................................................................. 19

-rilling 'showing details*............................................................................................................ 20

iltering...................................................................................................................................... 22

=pdating 'rereshing* changed !alues....................................................................................... 2)

Cell ormatting............................................................................................................................ 2)

=sing shortcuts.......................................................................................................................... 2)

-sing Pivot Table results elsewhere""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""#.

The problem...............................................................................................................................2)

The solution( unction G7T4BT-"T"....................................................................................2;$ynta................................................................................................................................... 2;irst synta !ariation............................................................................................................. 2@$econd synta !ariation........................................................................................................ 2@

Using Pivot Tables 3

Page 4: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 4/26

$mportant note

=nortunately+ due to the compleities o modern sotware+ the 4i!ot Table unction is incompletelyimplemented in this release '!).;* o Calc.

• The Group and Outline unctionality or any time inter!al is not a!ailable.

• The (ataPilot  dialog should ha!e been renamed to Pivot Table to match the parent

unction+ but this was not done.

B you wish to use this unction to its ull etent+ we strongly recommend that that you upgrade to&ibreice !ersion ).@+ which ully implements 4i!ot TableDs unctionality.

$ntroduction

any reEuests or sotware support are the result o using complicated ormulas and solutions tosol!e simple day to day problems. ore eicient and eecti!e solutions use the 4i!ot Table+ a toolor combining+ comparing+ and analyFing large amounts o data easily. =sing 4i!ot Tables+ you can!iew dierent summaries o the source data+ display the details o areas o interest+ and create

reports+ whether you are a beginner+ an intermediate or ad!anced user.

&atabase preconditions

The irst thing needed to wor% with the 4i!ot Table is a list o raw data+ similar to a database table+consisting o rows 'data sets* and columns 'data ields*. The ield names are in the irst row abo!ethe list.

The data source could be an eternal ile or database. or the simplest case+ where data iscontained in a Calc spreadsheet+ Calc oers sorting unctions that do not reEuire the 4i!ot Table.

or processing data in lists+ the program needs to %now where in the spreadsheet the table is. Thetable can be anywhere in the sheet+ in any position. " spreadsheet can contains se!eral unrelated

tables.

Calc recogniFes your lists automatically. Bt uses the ollowing logic( $tarting rom the cell youD!eselected 'which must be within your list*+ Calc chec%s the surrounding cells in all ; directions 'let+right+ abo!e+ below*. The border is recogniFed i the program disco!ers an empty row or column+ ori it hits the let or upper border o the spreadsheet.

This means that the described unctions can only wor% correctly i there are no empty rows orcolumns in your list. "!oid empty lines 'or eample or ormatting*. You can ormat your list byusing cell ormats.

/ule ?o empty rows or empty columns are allowed within lists.

B you select more than one single cell beore you start sorting+ iltering or calling the 4i!ot Table+then the automatic list recognition is switched o. Calc assumes that the list matches eactly thecells you ha!e selected.

/ule or sorting+ iltering+ or using the 4i!ot Table+ always select only one cell.

" relati!ely common source o errors is to inad!ertently declare a list by mista%e and then sort thelist. B you select multiple cells 'or eample+ a whole column* then the sorting mies up the datathat should be together in one row.

Bn addition to these ormal aspects+ the logical structure o your table is !ery important when using

the 4i!ot Table.

Using Pivot Tables

Page 5: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 5/26

/uleCalc lists must ha!e the nor#al for# that is+ they must ha!e a simple linearstructure.

3hen entering the data+ do not add outlines+ groups+ or summaries. ere are some mista%escommonly made by ineperienced spreadsheet users(

1* You made se!eral sheets+ or eample+ a sheet or each group o articles. "nalyses are

then possible only within each group. "nalyses or se!eral groups would be a lot o wor%.2* Bn the $ales list+ instead o only one column or the amount+ you made a column or the

amounts or each employee. The amounts then had to be entered into the appropriatecolumn. "n analysis with the 4i!ot Table would not be possible any more. Bn contrast+ oneresult o the 4i!ot Table is that you can get results or each employee i you ha!e enterede!erything in one column.

)* You entered the amounts in chronological order. "t the end o each month you made asum total. Bn this case+ sorting the list or dierent criteria is not possible because the 4i!otTable will treat the sum totals the same as any other igure. Getting monthly results is oneo the !ery ast and easy eatures o the 4i!ot Table.

&ata sources

"t this time+ the possible data sources or the 4i!ot Table are a Calc spreadsheet or an eternaldata source that has to be registered in &ibreice.

Calc spreadsheet 

The simplest and most oten used case is analyFing a list in a Calc spreadsheet. The list might beupdated regularly or the data might be imported rom a dierent application.

or eample+ a list can be copied rom a dierent application and pasted into Calc. The beha!ior oCalc while inserting the data depends on the ormat o the data. B the data is in a commonspreadsheet ormat+ it is copied directly into Calc. owe!er+ i the data is in plain tet+ the Tet

Bmport dialog 'igure 1* appears ater you select the ile containing the data see Chapter 1+Bntroducing Calc+ or more more inormation about this dialog.

Calc can import data rom a huge number o oreign data ormats+ or eample rom otherspreadsheets '7cel+ &otus 1+ 2+ )*+ rom databases 'li%e d,ase*+ and rom simple tet ilesincluding C$ ormats.

The drawbac% o copying or importing oreign data is that it will not update automatically i there arechanges in the source ile. 3ith a Calc ile you were pre!iously limited to <@+@)@ rows but this hasbeen epanded to 1+0;6+@:< rows.

Registered data source

" registered data source in &ibreice is a connection to data held in a database outside Calc.This means that the data to be analyFed will not be sa!ed in Calc Calc always uses the data romthe original source. Calc is able to use many dierent data sources and also databases that arecreated and maintained with &ibreice ,ase. $ee Chapter 10+ &in%ing Calc -ata+ or moreinormation.

ntroduction %

Page 6: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 6/26

$igure '* #port settings

Creating a Pivot Table

Create the 4i!ot Table using &ata > Pivot Table > Create rom the menu bar. B the list to beanalyFed is in a spreadsheet table+ select only one cell within this list. Calc recogniFes and selectsthe list automatically or use with the 4i!ot Table 'igure 2*.

The &ataPilot dialog

The unction o the 4i!ot Table is managed in two places( irst in the -ata4ilot dialog and secondthrough manipulations o the result in the spreadsheet. This section describes the dialog in detail.

0asic layout

Bn the -ata4ilot dialog 'igure )* are our white areas that show the layout o the result. ,esidethese white areas are buttons with the names o the ields in your data source. To choose a layout+drag and drop the ield buttons into the white areas.

The (ata $ields area in the middle must contain at least one ield. "d!anced users can use morethan one ield here. or the -ata ield an aggregate unction is used. or eample+ i you mo!e thesales ield into the (ata $ields area+ it appears there as 1um 2 sales.

/ Using Pivot Tables

Page 7: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 7/26

$igure 0* 1fter starting the Pivot Table

$igure 3* (ataPilot dialog

Ro, $ields and Colu#n $ields indicate rom which groups the result will be sorted. ten morethan one ield is used at a time to get partial sums or rows or columns. The order o the ieldsgi!es the order o the sums rom o!erall to speciic.

or eample+ i you drag region and employee into the Ro, $ields area+ the sum will be di!idedinto the employees. 3ithin the employees will be the listing or the dierent regions 'see igure ;*.

The (ataPilot dialog 2  

Page 8: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 8/26

$igure * (ataPilot field order for analsis4 and resulting laout in pivot table

ields that are placed into the Page $ields area appear in the result abo!e as a drop down list. Thesummary in your result ta%es only that part o your base data into account that you ha!e selected.or eample+ i you use employee as a 4age ield+ you can ilter the result shown or eachemployee.

To remo!e a ield rom the white layout area+ Hust drag it past the border and drop it 'the cursor will

change to a crossed symbol*+ or select it and clic% the /emove button.

More options

To epand the -ata4ilot dialog and show more options+ clic% More.

$igure %* 56panded dialog of the (ataPilot 

1election from$hows the sheet name and the range o cells used or the 4i!ot Table.

/esults toResults to deines where your result will be shown. $electing Results to as 2 undefined 2 andentering a cell reerence tells the 4i!ot Table where to show the results.1  "n error dialog is

displayed i you ail to enter a cell reerence. $electing Results to as 3 new sheet 2  adds anew sheet to the spreadsheet ile and places the results there. The new sheet is named usingthe ormat Pivot Table4sheet name45 where I is the number o the table created+ 1 or irst+2 or second and so on. or the source shown in igure )+ the new sheet or the irst tableproduced+ would be named Pivot Table4-msat6liste4+. 7ach new sheet is inserted net tothe source sheet.

$gnore empty rowsB the source data is not in the recommended orm+ this option tells the 4i!ot Table to ignoreempty rows.

1 Bn this case the word - undefined 7  is misleading because the output position is in act deined.

8 Using Pivot Tables

Page 9: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 9/26

$dentify categories3ith this option selected+ i the source data has missing entries in a list and does not meet therecommended data structure 'see igure <*+ the 4i!ot Table adds it to the listed category abo!eit. B this option is not chosen+ then the 4i!ot Table inserts !e#pt" 'see igure 6*.

$igure /* 56a#ple of data ,ith #issing entries in Colu#n 1

The option dentif categories ensures that in this eample rows ) and ; are included or theproduct 1pples and row < is included or Pears 'see igure :*.

$igure 2* Pivot Table result ,ith dentif categories selected 

3ithout category recognition+ the -ata4ilot shows an !e#pt" category 'igure 6*.

$igure 8* Pivot Table result ,ithout dentif categories selected 

&ogically+ the beha!ior with category recognition is better. " list showing missing entries is alsoless useul+ because you cannot use unctions such as sorting or iltering.

Total columns7 Total rows3ith these options you can decide i the 4i!ot Table shows an etra row with the sums o eachcolumn+ or i it adds on the !ery right a column with the sums o each row. Bn some cases+ anadded total sum is meaningless+ or eample i your entries are accumulated or the result o

comparisons.

Add filter=se this option to add or hide the cell labeled Filter abo!e the 4i!ot Table results. This cell is acon!enient button or additional iltering options within the 4i!ot Table.

8nable drill to details3ith this option enabled+ i you double#clic% on a single data cell+ including a cell produced romTotal colu#ns or Total ro,s+ in the 4i!ot Table result+ a new sheet opens gi!ing a detailedlisting o the indi!idual entry. B you double#clic% on either a cell in the Aow ields+ or Columnields+ then the &ho, (etail  dialog opens 'see J-rilling 'showing details*K on page 20*. Ta%ingigure ; as an eample+ i a pi!ot table uses more than one ield 'region and employee* and

you double#clic% a let#most ield 'say+ east*+ then this collapses the row+ combining the totals

The (ataPilot dialog

Page 10: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 10/26

or employees or that ield and displaying the totals or east . B this unction is disabled+ thedouble#clic% will %eep its usual edit unction within a spreadsheet.

More settings for the fields9 Field options

The options discussed in the pre!ious section are !alid or the -ata4ilot in general. You can alsochange settings or e!ery ield that you ha!e added to the -ata4ilot layout. -o this either byselecting a ield and clic%ing on the ptions button in the -ata4ilot dialog+ or by double#clic%ing onthe appropriate ield.

The options a!ailable or ields put into the -ata ields dier rom those put into the Aow+ Column+and 4age ields o the -ata4ilot.

Options for Data Fields

Bn the ptions dialog o a -ata ield you can select the $um unction or accumulating the !aluesrom your data source. You will oten use the sum unction+ but other unctions 'li%e standarddistribution or a counting unction* are also a!ailable. or eample+ the counting unction can beuseul or non#numerical data ields.

n the -ata ield dialog+ clic% More to see the (isplaed value section.

$igure * 56panded dialog for a (ata $ield 

Bn the (isplaed value section+ you can choose other possibilities or analysis by using theaggregate unction. -epending on the setting or Type+ you may ha!e to choose deinitions or0ase field and 0ase item.

$igure '9* 56a#ple choices for :ase field and ite#

'9 Using Pivot Tables

Page 11: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 11/26

The table below lists the possible types o displayed !alue and associated base ield and item+together with a note on usage.

Tpe !ase field !ase ite" #nalsis

?ormal L L $imple use o the chosenaggregate unction 'or eample+

sum*.

-ierencerom

$election o a ieldrom the data sourceo the -ata4ilot 'oreample+employee*.

$election o anelement rom theselected base ield 'oreample+ ,rigitte*.

The result is the dierencebetween the result o the ,aseield and the ,ase item 'oreample+ sales !olume o theemployees against the sales!olume o ,rigitte see igure 11*.

M o $election o a ieldrom the data sourceo the -ata4ilot 'oreample+ employee*

$election o anelement rom theselected base ield 'oreample+ ,rigitte*

The result is a percentage ratio othe !alue o the base ield to thebase item 'or eample+ salesresult o the employee relati!e to

the sales result o ,rigitte seeigure 12*.

Mdierencerom

$election o a ieldrom the data sourceo the -ata4ilot 'oreample+ employee*

$election o anelement rom theselected base ield 'oreample. ,rigitte*

rom each result+ its reerence!alue is subtracted+ and thedierence is di!ided by thereerence !alue 'or eample+sales o the employees as relati!edierence rom the sales o,rigitte see igure 1)*.

Aunningtotal in

$election o a ieldrom the data source

o the -ata4ilot 'oreample+ date*

L 7ach result is added to the sum othe results or preceding items in

the base ield+ in the base ieldDssort order+ and the total sum isshown.

Aesults are always summed+ e!eni a dierent summary unction wasused to get each result.

M o row L L The result is a percentage o the!alue o the whole row 'oreample+ the row sum*.

M ocolumn

L L The result is a percentage o thetotal column !alue 'or eample+

the column sum*.

M o total L L The result is a percentage o theo!erall result 'or eample+ thetotal sum*.

Bnde L L '-eault result total result* / 'rowtotal column total*

The (ataPilot dialog ''

Page 12: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 12/26

$igure ''* Original Pivot Table !top" and a Difference fro" e6a#ple !belo,"

$igure '0* 56a#ple of a $ of analsis

$igure '3* 56a#ple of $ difference fro" analsis

Options for Row and Colu"n Fields

Bn the ptions dialog or the Aow or Column ields+ you can choose to show subtotals or eachcategory. $ubtotals are deacti!ated by deault. They are only useul i the !alues in one row orcolumn ield can be di!ided into subtotals or another 'sub*ield.

$ome eamples are shown in the net three igures.

$igure '* ;o subdivision ,ith onl one ro, or colu#n field 

'0 Using Pivot Tables

Page 13: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 13/26

$igure '%* (ivision of the regions for e#ploees !t,o ro, fields" ,ithout subtotals

$igure '/* (ivision of the regions for e#ploees ,ith subtotals !b region"

The (ataPilot dialog '3

Page 14: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 14/26

Bn the $ubtotals section o the -ata ield dialog+ select the Automatic option to calculate subtotalsthat can also be used or the data ields 'see abo!e*.

You can choose the type o subtotal by selecting -ser3defined and then clic%ing the type osubtotal you want to calculate rom the list. unctions are only a!ailable when User-defined  isselected.

$igure '2* Preferences dialog of a ro, or colu#n field 

?ormally+ the 4i!ot Table does not show a row or column or categories that ha!e no entries in theunderlying database. ,y choosing the 1how items with no data  option+ you can orce this.

or illustration purposes+ the data was manipulated in such a way+ that the employee ,rigitte hasno sales !alues or the category goling.

$igure '8* (efault setting

$igure '* &etting <&ho, te#s ,ith no data= 

' Using Pivot Tables

Page 15: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 15/26

Options for %age Fields

The ptions dialog or 4age ields is the same as or Aow and Column ields+ e!en though itappears to be useless to ha!e the same settings as described or the Aow and Column ields. 3iththe leibility o the -ata4ilot you can switch the dierent ields between pages+ columns or rows.The ields %eep the settings that you made or them. The 4age ield has the same properties as aAow or Column ield. These settings only ta%e eect when you use the ield not as a 4age ield

but as Aow or Column ield.

(orking with the results of the &ataPilot )the Pivot Table*

"s mentioned abo!e+ the -ata4ilot dialog is !ery leible. "n analysis+ a 4i!ot Table+ can be totallyrestructured with only a ew mouse clic%s. $ome unctions o the -ata4ilot dialog can only be used with the 4i!ot Table.

Changing the layout

The layout o the 4i!ot Table can be changed Euic%ly and easily by drag and drop. 3ith the

-ata4ilot open+ ields can be dragged around rom row+ column+ page and the -ata ields areas toany position you want to put them+ and then dropped. =nused ields can be added+ and ieldsremo!ed in error can be replaced by dragging and dropping them into the positions reEuired.

$ome manipulation can also be carried out in the pi!ot table !iew. 3ithin the results table o the4i!ot Table+ mo!e one o the page+ column+ or row ields to a dierent position. The cursor willchange shape rom its starting shape 'horiFontal or !ertical bloc% on the arrow head* to theopposite i mo!ing to a dierent ield+ such as rom row to column+ and it is 8 to drop.

$igure 09* (rag a colu#n field. ;ote thecursor shape

 $igure 0'* (rag a ro, field. ;ote thecursor shape

You can remo!e a column+ row+ or page ield rom the 4i!ot Table by clic%ing on it and dragging itout o the table. The cursor changes to that shown in igure 22. " ield remo!ed in error cannot bereco!ered and it is necessary to return to the -ata4ilot to replace it.

$igure 00* $ield dragged out ofthe pivot table

:rouping rows or columns

or many analyses or summaries+ the categories ha!e to be grouped. You can merge the results inclasses. You can only carry out grouping on an ungrouped 4i!ot Table.

You can access grouping by selecting &ata > :roup and utline > :roup rom the menu bar+ orby pressing $'0 ater selecting the correct cell area. ow the grouping unction wor%s is

>orking ,ith the results of the (ataPilot !the Pivot Table" '%

Page 16: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 16/26

determined mainly by the type o !alues that ha!e to be grouped. You need to distinguish betweenscalar !alues+ or other !alues+ such as tet+ that you want grouped.

-ate and time !alues can not be grouped in this release o Calc 'see JBmportant noteK on page ;*.

Note

,eore you can group+ you ha!e to produce a 4i!ot Table with ungrouped data. Thetime needed or creating a 4i!ot Table depends mostly on the number o columns

and rows and not on the siFe o the basic data. Through grouping you can producethe 4i!ot Table with a small number o rows and columns. The 4i!ot Table cancontain a lot o categories+ depending on your data source.

:rouping of categories with scalar values

or grouping scalar !alues+ select a single cell in the row or column o the category to be grouped.

$igure 03* Pivot Table ,ithout grouping!fre?uenc of the k#+h values of aradar control"

$igure 0* Pivot Table ,ith grouping!classes of '9 k#+h each"

Choose &ata > :roup and utline > :roup rom the menu bar or press $'0 you get theollowing dialog.

$igure 0%* Grouping dialog ,ith scalar categories

'/ Using Pivot Tables

Page 17: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 17/26

You can deine in which !alue range 'start/end* the grouping should ta%e place. The deault settingis the whole range rom smallest to largest !alue. Bn the ield Group b  you can enter the classsiFe+ this means the inter!al siFe 'in this eample groups o 10 %m/h each*.

:rouping without automatic creation of intervals

Categories containing tet ields cannot create inter!als. You can deine or each ield 'or eample-epartment* which !alues you want to put together in one group.

$electing &ata > :roup and utline > :roup rom the menu bar+ or pressing $'04 with more thanone cell selected+ groups those cells.

$igure 0/* (atabase ,ith nonscalar categories!depart#ents"

$igure 02* Pivot Table,ith nonscalarcategories

or grouping o non scalar categories+ select in the result o the 4i!ot Table all the indi!idual ield!alues that you want to put in the one group.

Tip You can select se!eral non#contiguous cells in one step by pressing and holding theControl  %ey while let#clic%ing with the mouse.

Gi!en the input data shown in igure 2<+ eecute the 4i!ot Table with -epartment in the Aow ieldand $um '$ic% -ays* in the -ata ield. The output should loo% li%e that in igure 2:. $elect withthe mouse the -epartments "ccounting+ 4urchasing and $ales.

Choose the &ata  > :roup and utline > :roup rom the enu bar or press $'0. The outputshould now loo% li%e that in igure 26. Aepeat this or all groups that you want to create rom thedierent categories '$elect "ssembly+ 4roduction and 3arehouse and Group again. The outputshould loo% li%e igure 29.

$igure 08* &u##ar of single categories in onegroup

$igure 0* Grouping finished 

>orking ,ith the results of the (ataPilot !the Pivot Table" '2  

Page 18: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 18/26

You can change the deault names or the groups and the newly created group ield+ by editing thename in the input ield 'or eample changing NGroup0N to NTechnical N*. The 4i!ot Table willremember these settings+ e!en i you change the layout later on. or the ollowing pictures+ thedialog was called again 'with a right#clic%+ 8dit !ayout* and by selecting the icon J&epartment #K+then ptions+ and inally rom the preerences menu Automatic was selected. This generated thepartial sum results shown in igure )0. -ouble clic%ing :roup + and Technical collapses theentries+ as shown in igure )1.

$igure 39* Rena#ed groups and partial results

 $igure 3'* Reduced to the ne,groups

Note

" well#structured database ma%es manual sorting within the 4i!ot Table obsolete. Bnthe eample shown+ you could add another column with the name -epartment+ thathas the correct entry or each person based on whether the employeeDs departmentbelongs to the group ice or Technical. The mapping or this '1(n relationship* canbe done easily with the &8=4 unction rom Calc.

1orting the result

The result o any 4i!ot Table is sorted 'categories* in columns and rows in ascending order. Youcan change the sorting in three ways(

• $elect sort order rom drop#down menus on each column heading.

• $ort manually by using drag and drop.

• $ort automatically by choosing the options in the preerences dialog o the row or columnield.

&elect sort order fro" drop'down "enus on each colu"n heading

The simplest way to sort entries is to clic% the arrow on the right side o the heading and chec% thebo'es* or the desired sort order. The custom sorting dialog is shown in igure )). "dditionaloptions eist to show all + sho, onl the current ite#+ or hide onl the current ite#.

nce sorting has been carried out using the drop#down list+ the color o the arrow changes and asmall sEuare o matching color is added to the bottom right o the arrow button.

'8 Using Pivot Tables

Page 19: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 19/26

$igure 30* 1rro, color change and indicator s?uare on button

$igure 33* Custo# sorting

&ort "anuall ( using drag and drop

You can change the order within the categories by mo!ing the cells with the category !alues in theresult table o the 4i!ot Table. The cell will be inserted abo!e the cell on which you drop it.

,e aware that in Calc a cell must be selected. Bt is not enough that this cell contains the cell cursor.The bac%ground o a selected cell is mar%ed with a dierent color. To achie!e this+ clic% in one cell with no etra %ey pressed and redo this by pressing also the &hift  or Ctrl  %ey. "nother possibility isto %eep the mouse button pressed on the cell you want to select+ mo!e the mouse to a neighborcell and mo!e bac% to your original cell beore you release the mouse button.

&ort auto"aticall 

To sort automatically+ right#clic% within the 4i!ot Table and choose 8dit !ayout7 to open the-ata4ilot 'igure )*. 3ithin the &ayout area o the -ata4ilot+ double#clic% the row or column ieldyou want to sort. Bn the -ata ield dialog which opens 'igure 1:*+ clic% ptions to display the-ata ield ptions dialog.

or 1ort by choose either 1scending or (escending. n the let side is a drop#down list where youcan choose the ield this setting should apply to. 3ith this method you can speciy that sorting doesnot happen according to the categories but according to the results o the data ield.

>orking ,ith the results of the (ataPilot !the Pivot Table" '

Page 20: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 20/26

$igure 3* Options for a ro, or colu#n field 

&rilling )showing details*

-rill allows you to show the related detailed data or a single+ compressed !alue in the 4i!ot Tableresult. To acti!ate a drill+ double#clic% on the cell or choose &ata  > :roup and utline > 1how&etails. There are two possibilities(

1* The acti!e cell is a row or column ield.

Bn this case+ drill means an additional brea%down into the categories o another ield.

or eample+ double#clic% on the cell with the !alue golfing. Bn this instance the !alues thatare aggregated within golfing can be subdi!ided using another ield.

$igure 3%* :efore the drill do,n for the categor golfing

" dialog appears allowing you to select the ield to use or urther subdi!ision. Bn thiseample+ employee.

 09 Using Pivot Tables

Page 21: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 21/26

$igure 3/* &electing the field for the subdivision

$igure 32* 1fter the drill do,n

To hide the details again+ double#clic% on the cell golfing or choose &ata > :roup andutline > ;ide &etails.

The 4i!ot Table remembers your selection 'in our eample the ield employee* by addingand hiding the selected ield+ so that or the net drill down or a category in the ieldcategory the dialog does not appear. To remo!e the selection employee+ open the-ata4ilot dialog by right#clic%ing and choosing 8dit !ayout+ then delete the unwantedselection in the row or column ield.

2* The acti!e cell is a !alue o the -ata ield.

Bn this case+ drill down results in a listing o all data entries o the data source thataggregates to this !alue.

Bn our eample+ i we were to double#clic% on the cell with the !alue O16+:;1 rom igure)@+ we would now ha!e a new list o all data sets that are included in this !alue. This list isdisplayed in a new sheet.

>orking ,ith the results of the (ataPilot !the Pivot Table" 0'

Page 22: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 22/26

$igure 38* ;e, table sheet after the drill do,n for a value in a data field 

Filtering

To limit the 4i!ot Table analysis to a subset o the inormation that is contained in the data basis+you can ilter with the 4i!ot Table.

Note "n "utoilter or deault ilter used on the sheet has no eect on the -ata4ilot analysisprocess. The -ata4ilot always uses the complete list that was selected when it wasstarted.

To do this+ clic% Filter on the top let side abo!e the results.

$igure 3* $ilter field in the upper left area of the Pivot Table

Bn the ilter dialog+ you can deine up to ) ilter options that are used in the same way as CalcDsdeault ilter.

$igure 9* (ialog for defining the filter 

Note7!en i they are not called a ilter+ page ields are a practical way to ilter the results.The ad!antage is that the iltering criteria used are clearly !isible.

 00 Using Pivot Tables

Page 23: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 23/26

-pdating )refreshing* changed values

"ter you ha!e created the 4i!ot Table+ changes in the source data do not cause an automaticupdate in the resulting table. You must update 'reresh* the 4i!ot Table manually ater changingany o the underlying data !alues.

Changes in the source data could appear in two ways(

1* The content o eisting data sets has been changed.or eample+ you might ha!e changed a sales !alue aterward. To update the 4i!ot Table+right#clic% in the result area and choose /efresh 'or choose &ata  > Pivot Table > /efreshrom the menu bar*.

2* You ha!e added or deleted data sets in the original list.

Bn this case the change means that the 4i!ot Table has to use a dierent area o thespreadsheet or its analysis. undamental changes to the data set collection means youmust redo the 4i!ot Table rom the beginning.

Cell formatting

The cells in the results area o the 4i!ot Table are automatically ormatted in a simple ormat by

Calc. You can change this ormatting using all the tools in Calc+ but note that i you ma%e anychange in the design o the 4i!ot Table or any updates+ the ormatting will return to the ormatapplied automatically by Calc.

or the number ormat in the data ield+ Calc uses the number ormat that is used in thecorresponding cell in the source list. Bn most cases+ this is useul 'or eample+ i the !alues are inthe currency ormat+ then the corresponding cell in the result area is also ormatted as currency*.owe!er+ i the result is a raction or a percentage+ the 4i!ot Table does not recogniFe that thismight be a problem such results must either be without a unit or be displayed as a percentage."lthough you can correct the number ormat manually+ the correction stays in eect only until thenet update.

-sing shortcuts

B you use the 4i!ot Table !ery oten+ you might ind the reEuent use o the menu paths '&ata  >Pivot Table > Create and &ata > :roup and utline > :roup* incon!enient.

or grouping+ a shortcut is already deined( $'0. or starting the 4i!ot Table+ you can deine yourown %eyboard shortcut. B you preer to ha!e toolbar icons instead o %eyboard shortcuts+ you cancreate a user#deined symbol and add it to either your own custom made toolbar or the $tandardtoolbar.

or an eplanation how to create %eyboard shortcuts or add icons to toolbars+ see Chapter 1;+$etting =p and CustomiFing Calc.

-sing Pivot Table results elsewhere

The problem

?ormally you create a reerence to a !alue by entering the address o the cell that contains the!alue. or eample+ the ormula =C6*2 creates a reerence to cell C' and returns the doubled

!alue.

B this cell is located in the results area o the 4i!ot Table+ it contains the result that was calculatedby reerencing speciic categories o the row and column ields. Bn igure ;1+ the cell C' containsthe sum o the sales !alues o the employee ans in the category $ailing. The ormula in the cell

C+# uses this !alue.

Using Pivot Table results else,here 03

Page 24: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 24/26

$igure '* $or#ula reference to a cell of the Pivot Table

B the underlying data or the layout o the 4i!ot Table changes+ then you must ta%e into account that

the sales !alue or ans might appear in a dierent cell. Your ormula still reerences the cell C'and thereore uses a wrong !alue. The correct !alue is in a dierent location. or eample+ inigure ;2+ the location is now C<.

$igure 0* The value that ou reall ,ant to use can be found no, in a differentlocation.

The solution9 Function :8TP$=T&ATA=se the unction G7T4BT-"T" to ha!e a reerence to a !alue inside the 4i!ot Table by usingthe speciic identiying categories or this !alue. This unction can be used with ormulas in Calc iyou want to reuse the results rom the 4i!ot Table elsewhere in your spreadsheet.

&ntax 

The synta has two !ariations(

GETPIVOTDATA(target field, Pivot Table, [ Field a!e " Ele!et, ### $%

GETPIVOTDATA(Pivot Table, &'eifiatio%

 0 Using Pivot Tables

Page 25: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 25/26

First sntax variation

The target field speciies which data ield o the 4i!ot Table is used within the unction. B your4i!ot Table has only one data ield+ this entry is ignored+ but you #ust  enter it anyway.

B your 4i!ot Table has more than one data ield+ then you ha!e to enter the ield name rom theunderlying data source 'or eample JsalesK* or the ield name o the data ield itsel 'or eampleJsum – salesK*.

The argument Pivot Table speciies the 4i!ot Table that you want to use. Bt is possible that yourdocument contains more than one 4i!ot Table. 7nter here a cell reerence that is inside the area oyour 4i!ot Table. Bt might be a good idea to always use the upper let corner cell o your 4i!otTable+ so you can be sure that the cell will always be within your 4i!ot Table+ e!en i the layoutchanges.

7ample( GETPIVOTDATA()&ale&),A%

B you enter only the irst two arguments+ then the unction returns the total  result o the 4i!ot Table'J$um – salesK entered as the ield+ will return a !alue o ;06+:<@*.

You can add more arguments as pairs with field name and item to retrie!e speciic partial sums.Bn the eample in igure ;1+ where we want to get the partial sum o ans or sailing+ the ormula

in cell C+# would loo% li%e this(

=GETPIVOTDATA()&ale&),A,)e!'lo+ee),)a&),)ategor+),)&ailig)%

$igure 3* $irst snta6 variation

&econd sntax variation

The argument Pivot Table has to be gi!en in the same way as or the irst synta !ariation.or the specifications+ enter a list separated by spaces to speciy the !alue you want rom the4i!ot Table. This list must contain the name o the data ield+ i there is more than one data ieldotherwise it is not reEuired. To select a speciic partial result+ add more entries in the orm o

Field a!e[ite!$.

Bn the eample in igure ;1+ where we want to get the partial sum o ans or $ailing+ the ormulain cell C+# would loo% li%e this(

=GETPIVOTDATA(A,)&ale& e!'lo+ee[a&$ ategor+[&ailig$)%

Using Pivot Table results else,here 0%

Page 26: PivotTables Tutorial

7/21/2019 PivotTables Tutorial

http://slidepdf.com/reader/full/pivottables-tutorial 26/26

$igure * &econd snta6 variation

3hen wor%ing with data sets containing date inormation+ you must ta%e care i you use the dateinormation in the G7T4BT-"T" unction. The unction will only recogniFe the date entry i it isentered into the ormula in eactly the same way that it appears in the data set rom which the pi!ottable is produced. Bn the eample o igure ;@+ an error is returned when the date ormat does notmatch that o the data. nly with the correct ormat is the result returned.

$igure %* 5rror produced if date infor#ation is not entered in correctl 

0/ U i Pi t T bl