<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Peltier Tech Blog &#187; Pivot Tables</title>
	<atom:link href="http://peltiertech.com/WordPress/category/pivot-tables/feed/" rel="self" type="application/rss+xml" />
	<link>http://peltiertech.com/WordPress</link>
	<description>Peltier Tech Excel Charts and Programming Blog</description>
	<lastBuildDate>Tue, 07 Feb 2012 14:40:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Referencing Pivot Table Ranges in VBA</title>
		<link>http://peltiertech.com/WordPress/referencing-pivot-table-ranges-in-vba/</link>
		<comments>http://peltiertech.com/WordPress/referencing-pivot-table-ranges-in-vba/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 06:00:30 +0000</pubDate>
		<dc:creator>Jon Peltier</dc:creator>
				<category><![CDATA[Pivot Tables]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=2310</guid>
		<description><![CDATA[I&#8217;ve posted several examples of manipulating pivot tables with VBA, for example, Dynamic Chart using Pivot Table and VBA and Update Regular Chart when Pivot Table Updates. These examples included specific procedures, and the emphasis was on the results of the manipulation. I thought it would be helpful to show some of the mechanics of [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve posted several examples of manipulating pivot tables with VBA, for example, <a href="http://peltiertech.com/WordPress/dynamic-chart-using-pivot-table-and-vba/"title="Dynamic Chart using Pivot Table and VBA | PTS Blog" >Dynamic Chart using Pivot Table and VBA</a> and <a href="http://peltiertech.com/WordPress/update-regular-chart-when-pivot-table-updates/"title="Update Regular Chart when Pivot Table Updates | PTS Blog" >Update Regular Chart when Pivot Table Updates</a>. These examples included specific procedures, and the emphasis was on the results of the manipulation.</p>
<p>I thought it would be helpful to show some of the mechanics of programming with pivot tables. One important part of this is referencing the various ranges within a pivot table by their special VBA range names (which are actually properties of the Pivot Table object).</p>
<p>I&#8217;ll illustrate these special ranges using this simple pivot table, which comes from an example formerly available on the Microsoft web site (I can no longer locate it).</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PivotTable.png" alt="Pivot Table" /></p>
<p><span id="more-2310"></span>In VBA, you can reference a pivot table using this code in a procedure:</p>
<p><tt class="tt">Dim pt As PivotTable<br />
 Set pt = ActiveSheet.PivotTables(1)</tt></p>
<p>I&#8217;ve highlighted the various ranges using the indicated VBA commands.</p>
<p><strong><em>TableRange1</em></strong></p>
<p><tt class="tt">pt.TableRange1.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTTableRange1.png" alt="Pivot Table - Table Range 1" /></p>
<p><strong><em>TableRange2</em></strong></p>
<p><tt class="tt">pt.TableRange2.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTTableRange2.png" alt="Pivot Table - Table Range 2" /></p>
<p><strong><em>RowRange</em></strong></p>
<p><tt class="tt">pt.RowRange.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTRowRange.png" alt="Pivot Table - Row Range" /></p>
<p><strong><em>ColumnRange</em></strong></p>
<p><tt class="tt">pt.ColumnRange.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTColumnRange.png" alt="Pivot Table - Column Range" /></p>
<p><strong><em>DataLabelRange</em></strong></p>
<p><tt class="tt">pt.DataLabelRange.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTDataLabelRange.png" alt="Pivot Table - Data Label Range" /></p>
<p><strong><em>DataBodyRange</em></strong></p>
<p><tt class="tt">pt.DataBodyRange.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTDataBodyRange.png" alt="Pivot Table - Data Body Range" /></p>
<p><strong><em>PageRange</em></strong></p>
<p><tt class="tt">pt.PageRange.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTPageRange.png" alt="Pivot Table - Page Range" /></p>
<p><strong><em>Pivot Field LabelRange</em></strong></p>
<p><tt class="tt">pt.PivotFields("Years").LabelRange.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTPFyearsLabelRange.png" alt="Pivot Table - Pivot Field Label Range" /></p>
<p><strong><em>PivotField DataRange</em></strong></p>
<p><tt class="tt">pt.PivotFields("Years").DataRange.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTPFyearsDataRange.png" alt="Pivot Table - Pivot Field Data Range" /></p>
<p><strong><em>Pivot Item LabelRange</em></strong></p>
<p><tt class="tt">pt.PivotFields("Years").PivotItems("2004").LabelRange.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTPFyearsPI2004LabelRange.png" alt="Pivot Table - Pivot Item Label Range" /></p>
<p><strong><em>Pivot Item DataRange</em></strong></p>
<p><tt class="tt">pt.PivotFields("Years").PivotItems("2004").DataRange.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTPFyearsPI2004DataRange.png" alt="Pivot Table - Pivot Item Data Range" /></p>
<p><tt class="tt">pt.PivotFields("Order Date").PivotItems("Feb").DataRange.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTPFdatePIfebDataRange.png" alt="" /></p>
<p><strong><em>Pivot Field LabelRange</em></strong></p>
<p>The next few examples show the same ranges as above, after pivoting the table&#8217;s Years field from the columns area to the rows area.</p>
<p><tt class="tt">pt.PivotFields("Years").LabelRange.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTPFyearsDataRangeA.png" alt="Pivot Table - Pivot Field Data Range" /></p>
<p><strong><em>Pivot Item LabelRange</em></strong></p>
<p><tt class="tt">pt.PivotFields("Years").PivotItems("2004").LabelRange.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTPFyearsPI2004LabelRangeA.png" alt="Pivot Table - Pivot Item Label Range" /></p>
<p><strong><em>Pivot Item DataRange</em></strong></p>
<p><tt class="tt">pt.PivotFields("Years").PivotItems("2004").DataRange.Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTPFyearsPI2004DataRangeA.png" alt="Pivot Table - Pivot Field Data Range" /></p>
<p><strong><em>Complex Range</em></strong></p>
<p>If a particular range isn&#8217;t specifically defined with a VBA property, you can use VBA range-extending properties <tt class="tt">EntireColumn</tt> and <tt class="tt">EntireRow</tt> and range operators <tt class="tt">Union</tt> and <tt class="tt">Intersect</tt> to define the range. For example:</p>
<p><tt class="tt">Intersect(pt.PivotFields("Years").Pivotitems("2004").DataRange.EntireRow, pt.PivotFields("Order Date").DataRange).Select</tt></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/2009-08/PTPFyrsPI2003entirerowINTPForderdatedatarange.png" alt="Pivot Table - Complex Data Range" /></p>
<p>Peltier Technical Services, Inc., Copyright © 2011.<br /> <br /><span style="font: 80% Verdana,Tahoma,Arial,sans-serif;">Licensed under a <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/" rel="nofollow" rel="license" >Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>.<br /> <br />
<a href="http://peltiertech.com/Utility/" rel="nofollow"  title="PTS Chart Utilities: Waterfall, Cluster-Stack Column, Box and Whisker, Marimekko"><img src="http://peltiertech.com/Utility/pix/pts_banner_map.png" alt="PTS Chart Utilities: Waterfall, Box and Whisker, Cluster-Stack, Panel, Marimekko, Dot, Panel" border="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://peltiertech.com/WordPress/referencing-pivot-table-ranges-in-vba/feed/</wfw:commentRss>
		<slash:comments>159</slash:comments>
		</item>
		<item>
		<title>Explore Your Data With Pivot Tables</title>
		<link>http://peltiertech.com/WordPress/explore-your-data-with-pivot-tables/</link>
		<comments>http://peltiertech.com/WordPress/explore-your-data-with-pivot-tables/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 11:00:16 +0000</pubDate>
		<dc:creator>Jon Peltier</dc:creator>
				<category><![CDATA[Pivot Tables]]></category>

		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=896</guid>
		<description><![CDATA[Pivot tables are one of Excel&#8217;s most outstanding features. They allow fast dynamic and interactive analysis of data from the workbook or from any number of external sources. Pivot charts go hand in hand with pivot tables in showing the data visually. I am not a staunch fan of pivot charts: they allow only a [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Pivot tables</strong> are one of Excel&#8217;s most outstanding features. They allow fast dynamic and interactive analysis of data from the workbook or from any number of external sources. Pivot charts go hand in hand with pivot tables in showing the data visually. I am not a staunch fan of pivot charts: they allow only a limited selection of chart types, and their formatting possibilities are not as extensive as those of regular charts. however, for a quick look into a new data set, they are hard to beat. Later when I know what I want to show, I make custom regular charts, with data often derived from pivot tables.</p>
<p>In <a href="http://chandoo.org/wp/2008/09/18/excel-charting-problem-how-to-show-market-share-in-2-different-periods/" rel="nofollow" title="Visualization Challenge - How to show market share changes?" >Visualization Challenge &#8211; How to show market share changes?</a> our colleague <strong>Chandoo</strong> presented the following data and challenged his readers to display it meaningfully. The data shows market share for two brands and five competing retailers, at two times. The challenge was to show the trends over time. I took on this challenge in <a href="http://peltiertech.com/WordPress/2008/11/10/challenge-show-market-share-changes/"title="Challenge - Show Market Share Changes" >Challenge &#8211; Show Market Share Changes</a>. While working on this challenge, I realized that the data made for a good example of the power of pivot tables for fast and detailed analysis.<span id="more-896"></span></p>
<h2 style="margin: 0pt 0pt 18px; font-size: 1em;">Pivot Table Data</h2>
<p>I&#8217;ve rearranged Chandoo&#8217;s sample data into the form required for an effective pivot table. There are no blank rows or columns, the first row has headers (field names), and there is one row (record) per observation.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" title="Pivot Table Data" src="http://peltiertech.com/WordPress/wp-content/img200811/pt_data.png" alt="Pivot Table Data" /></p>
<h2 style="margin: 0pt 0pt 18px; font-size: 1em;">Pivot Tables and Charts</h2>
<p>To create a pivot table, select all of the data or a single cell within the data (Excel will try to use the contiguous range surrounding the selected cell), and from the Data menu or the Insert tab in 2007, choose Pivot Table. To include a pivot chart, you can choose the appropriate option in the dialogs, or you can select the pivot table and insert a chart, or (and this can be dangerous) you can select an existing chart, edit the source data, click in the Data Range entry box, and click in the pivot table. This last operation is dangerous, because it converts the chart into a pivot chart, and pivot charts cannot be reverted to regular charts. Of course, it is possible to create <a href="http://peltiertech.com/WordPress/2008/06/13/regular-charts-from-pivot-tables/"title="Regular Charts from Pivot Tables" >Regular Charts from Pivot Tables</a>.</p>
<p>The pivot chart is joined to the pivot table at the hip. Any changes to the pivot table are reflected in the pivot chart, and vice versa. For clarity, I have hidden the pivot buttons from these pivot charts. They are redundant since the pivot table and chart are so close together, and they consume valuable chart real estate.</p>
<p>This first arrangement shows each competitor as a different color series. This is fine, but there is too much spacial separation between the two times to allow a good assessment of the trends.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" title="Pivot Table - Time and Brand vs. Comp" src="http://peltiertech.com/WordPress/wp-content/img200811/pt_col_timebrand_comp.png" alt="Pivot Table - Time and Brand vs. Comp" /></p>
<p>This is easy to fix with a pivot table. You can click and drag the gray field buttons around to change the arrangement instantly. So I dragged the time field inside the product field. The times are closer, but the trends are still not so easy to discern.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" title="Pivot Table - Brand and Time vs. Comp" src="http://peltiertech.com/WordPress/wp-content/img200811/pt_col_brandtime_comp.png" alt="Pivot Table - Brand and Time vs. Comp" /></p>
<p>Okay, maybe the competitors shouldn&#8217;t rank their own series. I dragged the competitor field down to the rows area and the product field up to the columns area. Hmm, the times are again too far apart.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" title="Pivot Table - Time and Comp vs. Brand" src="http://peltiertech.com/WordPress/wp-content/img200811/pt_col_timecomp_brand.png" alt="Pivot Table - Time and Comp vs. Brand" /></p>
<p>Click, drag. Okay, the times are pretty close now, but the comparison between brands is given more emphasis.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" title="Pivot Table - Comp and Time vs. Brand" src="http://peltiertech.com/WordPress/wp-content/img200811/pt_col_comptime_brand.png" alt="Pivot Table - Comp and Time vs. Brand" /></p>
<p>So if we swap the time and product fields, we put the data for the two corresponding time periods next to each other. This view compares the competitors for each brand&#8230;</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" title="Pivot Table - Brand and Comp vs. Time" src="http://peltiertech.com/WordPress/wp-content/img200811/pt_col_brandcomp_time.png" alt="Pivot Table - Brand and Comp vs. Time" /></p>
<p>&#8230; while this view compares the two brands for each competitor.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" title="Pivot Table - Comp and Brand vs. Time" src="http://peltiertech.com/WordPress/wp-content/img200811/pt_col_compbrand_time.png" alt="Pivot Table - Comp and Brand vs. Time" /></p>
<h2 style="margin: 0pt 0pt 18px; font-size: 1em;">The Ultimate Chart</h2>
<p>This analysis gave me just enough insight to know how I should build the chart I answered Chandoo&#8217;s challenge with. It was not a pivot chart, nor was it based directly on a pivot table, but it utilized the insights from the analysis above. I created a panel chart with each competitor in its own vertical panel, and with lines connecting the data.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" title="compound panel chart" src="http://peltiertech.com/WordPress/wp-content/img200811/compoundpanel.png" alt="compound panel chart" /></p>
<p>I&#8217;ll show the particular data arrangement and protocol I used to create this chart in an upcoming post. Stay tuned.</p>
<h2 style="margin: 0pt 0pt 18px; font-size: 1em;">More About Pivot Tables</h2>
<p>For more about pivot tables, check out these web pages, mostly from my site:</p>
<ul style="margin-left: 24px;">
<li><a href="http://peltiertech.com/Excel/Pivots/pivotstart.htm" rel="nofollow" >Pivot Tables and Pivot </a></li>
<li><a href="http://peltiertech.com/Excel/Pivots/pivotstart.htm" rel="nofollow" ><strong>Pivot Tables and Pivot Charts</strong></a><br />
 &#8211; Contributed by fellow Excel MVP Debra Dalgleish. Check out Debra’s <a href="http://www.contextures.com/tiptech.html" rel="nofollow"  target="_blank">Excel Tips page</a><br />
 &#8211; <a href="http://peltiertech.com/Excel/Pivots/pivottables.htm" rel="nofollow" >Introduction to Pivot Tables in Excel</a><br />
 &#8211; <a href="http://peltiertech.com/Excel/Pivots/pivotcharts.htm" rel="nofollow" >Working with Pivot Charts in Excel</a><br />
 &#8211; <a href="http://peltiertech.com/Excel/Pivots/pivotvba.htm" rel="nofollow" >Pivot Table Programming</a><br />
 &#8211; <a href="http://peltiertech.com/Excel/Pivots/pivotlinks.htm" rel="nofollow" >Pivot Table and Pivot Chart Links</a></li>
<li><a href="http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=553" rel="nofollow" >Pivot Tables, Pivot Charts, and Real Charts</a> <em>(TechTrax Article)</em></li>
<li><strong>Pivot Table Articles on the Peltier Tech Blog</strong><br />
 &#8211; <a href="http://peltiertech.com/WordPress/explore-your-data-with-pivot-tables/"title="Explore Your Data With Pivot Tables | Peltier Tech Blog" >Explore Your Data With Pivot Tables</a><br />
 &#8211; <a href="http://peltiertech.com/WordPress/preliminary-data-exploration-with-excel-pivot-tables/"title="Preliminary Data Exploration with Excel Pivot Tables | Peltier Tech Blog" >Preliminary Data Exploration with Excel Pivot Tables</a><br />
 &#8211; <a href="http://peltiertech.com/WordPress/regular-charts-from-pivot-tables/"title="Making Regular Charts from Pivot Tables | Peltier Tech Blog" >Making Regular Charts from Pivot Tables</a><br />
 &#8211; <a href="http://peltiertech.com/WordPress/update-regular-chart-when-pivot-table-updates/"title="Update Regular Chart when Pivot Table Updates | Peltier Tech Blog" >Update Regular Chart when Pivot Table Updates</a><br />
 &#8211; <a href="http://peltiertech.com/WordPress/using-pivot-table-data-for-a-chart-with-a-dual-category-axis/"title="Using Pivot Table Data for a Chart with a Dual Category Axis | Peltier Tech Blog" >Using Pivot Table Data for a Chart with a Dual Category Axis</a><br />
 &#8211; <a href="http://peltiertech.com/WordPress/grouping-by-date-in-a-pivot-table/"title="Grouping by Date in a Pivot Table | Peltier Tech Blog" >Grouping by Date in a Pivot Table</a><br />
 &#8211; <a href="http://peltiertech.com/WordPress/referencing-pivot-table-ranges-in-vba/"title="Referencing Pivot Table Ranges in VBA | Peltier Tech Blog" >Referencing Pivot Table Ranges in VBA</a><br />
 &#8211; <a href="http://peltiertech.com/WordPress/copy-pivot-table-pivot-chart-link-to-new-data/"title="Copy a Pivot Table and Pivot Chart and Link to New Data | Peltier Tech Blog" >Copy a Pivot Table and Pivot Chart and Link to New Data</a><br />
 &#8211; <a href="http://peltiertech.com/WordPress/pivot-table-conditional-formatting-with-vba/"title="Pivot Table Conditional Formatting with VBA | Peltier Tech Blog" >Pivot Table Conditional Formatting with VBA</a><br />
 &#8211; <a href="http://peltiertech.com/WordPress/dynamic-chart-using-pivot-table-and-range-names/"title="Dynamic Chart using Pivot Table and Range Names | Peltier Tech Blog" >Dynamic Chart using Pivot Table and Range Names</a><br />
 &#8211; <a href="http://peltiertech.com/WordPress/dynamic-chart-using-pivot-table-and-vba/"title="Dynamic Chart using Pivot Table and VBA | Peltier Tech Blog" >Dynamic Chart using Pivot Table and VBA</a></li>
<li><a href="http://peltiertech.com/Excel/xlbooks.html#PTAnalysis" rel="nofollow" >Books on Excel Pivot Tables</a><br />
 &#8211; <a href="http://www.amazon.com/gp/redirect.html%3FASIN=1590596293%26tag=peltiertechni-20%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Excel-Pivot-Tables-Recipe-Book/dp/1590596293%253FSubscriptionId=02E5W5871AJF7PMMMS82" rel="nofollow" >Excel Pivot Tables Recipe Book: A Problem-Solution Approach</a> by Debra Dalgleish<br />
 &#8211; <a href="http://www.amazon.com/gp/redirect.html%3FASIN=1590598903%26tag=peltiertechni-20%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Beginning-PivotTables-Excel-2007-Professional/dp/1590598903%253FSubscriptionId=02E5W5871AJF7PMMMS82"rel="nofollow" >Beginning PivotTables in Excel 2007: From Novice to Professional</a> by Debra Dalgleish<br />
 &#8211; <a href="http://www.amazon.com/gp/redirect.html%3FASIN=0789734354%26tag=peltiertechni-20%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Pivot-Table-Crunching-Business-Solutions/dp/0789734354%253FSubscriptionId=02E5W5871AJF7PMMMS82"rel="nofollow" >Pivot Table Data Crunching</a> by Bill Jelen and Michael Alexander<br />
 &#8211; <a href="http://www.amazon.com/gp/redirect.html%3FASIN=0789736012%26tag=peltiertechni-20%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Crunching-Microsoft-Office-Business-Solutions/dp/0789736012%253FSubscriptionId=02E5W5871AJF7PMMMS82"rel="nofollow" >Pivot Table Data Crunching for Microsoft Office Excel 2007</a> by Bill Jelen and Michael Alexander</li>
</ul>
<p style="text-align: center;"><a href="http://www.amazon.com/gp/product/1590598903?ie=UTF8&amp;tag=peltiertechni-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1590598903"title="Debra Dalgleish - Beginning PivotTables in Excel 2007" rel="nofollow" ><img src="http://peltiertech.com/images/books/PivotTablesInExcel2007.jpg" border="0" alt="" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=peltiertechni-20&amp;l=as2&amp;o=1&amp;a=1590598903" border="0" alt="" width="1" height="1" /> <a href="http://www.amazon.com/gp/product/1590599209?ie=UTF8&amp;tag=peltiertechni-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1590599209"title="Debra Dalgleish - Excel 2007 PivotTables Recipes" rel="nofollow" ><img src="http://peltiertech.com/images/books/Excel2007PivotTableRecipes.jpg" border="0" alt="" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=peltiertechni-20&amp;l=as2&amp;o=1&amp;a=1590599209" border="0" alt="" width="1" height="1" /> <a href="http://www.amazon.com/gp/product/0789736012?ie=UTF8&amp;tag=peltiertechni-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0789736012"title="Bill Jelen and Mike Alexander - Pivot Table Data Crunching for Microsoft Office Excel 2007" rel="nofollow" ><img src="http://peltiertech.com/images/books/PivotTableDataCrunching2007.jpg" border="0" alt="" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=peltiertechni-20&amp;l=as2&amp;o=1&amp;a=0789736012" border="0" alt="" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://peltiertech.com/WordPress/explore-your-data-with-pivot-tables/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Making Regular Charts from Pivot Tables</title>
		<link>http://peltiertech.com/WordPress/regular-charts-from-pivot-tables/</link>
		<comments>http://peltiertech.com/WordPress/regular-charts-from-pivot-tables/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 10:30:49 +0000</pubDate>
		<dc:creator>Jon Peltier</dc:creator>
				<category><![CDATA[Pivot Tables]]></category>
		<category><![CDATA[pivot chart]]></category>

		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=115</guid>
		<description><![CDATA[Sometimes it&#8217;s desirable to make a regular chart from a pivot table, but Excel makes it difficult. If your active cell is in a pivot table, inserting a chart automatically inserts a pivot chart. Defining a source data range that intersects a pivot table automatically converts the chart into a pivot table. And once a [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes it&#8217;s desirable to make a regular chart from a pivot table, but Excel makes it difficult. If your active cell is in a pivot table, inserting a chart automatically inserts a pivot chart. Defining a source data range that intersects a pivot table automatically converts the chart into a pivot table. And once a chart becomes a pivot chart, it cannot be converted back into a regular chart.</p>
<p>In a moment I&#8217;ll show how to make a regular chart from a pivot table&#8217;s data. But first let&#8217;s review some of the strengths and weaknesses of pivot charts.</p>
<p>Pivot charts have some advantages over regular charts:</p>
<ul>
<li>Pivot charts are dynamic</li>
<li>Pivot charts are interactive</li>
<li>Pivot charts can be pivoted</li>
</ul>
<p><span id="more-115"></span>However, the same infrastructure that conveys these advantages also results in some shortcomings:</p>
<ul>
<li>Some chart types (XY) are not available to pivot charts</li>
<li>The date scale axis is not available in pivot charts</li>
<li>All data from the pivot table must be included in the pivot chart</li>
<li>Data from outside the pivot table cannot be included in the pivot chart</li>
<li>Pivot chart formatting options are limited (alleviated to some extent in Excel 2007)</li>
<li>Pivot chart formatting may be lost when the pivot table is changed</li>
</ul>
<p>When pivot charts were first introduced in Excel 2000, I was excited by the possibilities, yet discouraged by their limitations. I rarely used pivot charts because I felt the limitations far outweighed their capabilities. The formatting capabilities in Excel 2007 are much less constricting than in Excel 2003, so I am more likely to use pivot charts in 2007. While<a href="http://peltiertech.com/WordPress/why-i-dont-like-excel-2007-charts/"class="vt-p" title="Why I don't like Excel 2007 charts" > I strongly dislike working with Excel 2007 charts</a>, Excel 2007 pivot charts are greatly improved. The restrictions on pivot chart data sources are still limiting.</p>
<p>Microsoft hosts a number of decent Pivot Table examples. I will use one of them for this tutorial. Go to the Microsoft example <a href="http://office.microsoft.com/en-gb/excel/HA010346331033.aspx" rel="nofollow" class="vt-p" >25 easy PivotTable reports</a>, which has a link to <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=5E720455-FD3F-47BB-96BF-94819AA214C4&amp;displaylang=en" rel="nofollow" class="vt-p" >Excel 2002 Sample: PivotTable Reports</a>. From this page you can download a self-extracting executable named <tt class="tt">Reports.exe</tt>, which contains four workbooks. The top few records of the <tt class="tt">Source Data</tt> worksheet of the <tt class="tt">SampleSalespersonReports.xls</tt> workbook looks like this:</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://peltiertech.com/WordPress/wp-content/img200806/PT_sourcedata.png" alt="Pivot Table Source Data" /></p>
<p>To create a pivot table in Excel 2003, select one cell within this data range, and choose <tt class="tt">Pivot Table and Pivot Chart Report</tt> from the Data menu. To keep things uncomplicated, place the pivot table onto a new worksheet. Drag the <tt class="tt">Order Date</tt> field to the rows area, the <tt class="tt">Country</tt> field to the Columns area, and the <tt class="tt">Order Amount</tt> field to the Data area. Group the <tt class="tt">Order Date</tt> field by month and year as described in <a href="http://peltiertech.com/WordPress/2008/06/11/grouping-by-date-in-a-pivot-table/"class="vt-p" >Grouping by Date in a Pivot Table</a>.</p>
<p>In 2007, select a cell in the data range, and choose PivotTable from the Insert ribbon tab. By default, manipulation of the fields is done in a Pivot Table Field List pane, not in the worksheet. You can override this setting if you&#8217;re willing to trade the new pivot capabilities introduced in 2007 for the convenient but apparently old-fashioned on-sheet button manipulation. In the PivotTable Field List, check the boxes in front of the fields you want in the pivot table, then drag them to the appropriate areas at the bottom of the pane. It&#8217;s basically the same as in 2003, just within the task pane.</p>
<p>The resulting pivot table looks like this:</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://peltiertech.com/WordPress/wp-content/img200806/PT_bydatecountry.png" alt="Pivot Chart by Date and by Country" /></p>
<p>To make a pivot chart, select any part of the pivot table and insert a chart. Excel 2007 places the pivot chart on the active worksheet.</p>
<p>In Excel 2003 and earlier, by default the pivot table is created on its own chart sheet. This is rather inconvenient, since I always move the pivot chart to the same worksheet as the pivot table anyway. To avoid this sheet switching, I select a blank cell that isn&#8217;t touching the pivot table, and insert a chart without specifying any data. I then select the blank chart, invoke the Source Data command, and click in the pivot table, which instantly turns the chart into a pivot chart associated permanently with this pivot table.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://peltiertech.com/WordPress/wp-content/img200806/PCht_bydatecountry.png" alt="Pivot Chart by Date and by Country" /></p>
<p>The pivot chart is linked to the pivot table, so any changes to the pivot table are reflected in the chart. In Excel 2003, the same dragging around of field buttons to pivot the table can also be accomplished in the chart, and the pivot table keeps up. A regular chart is not dynamic in this way. You could write VBA procedures that detect a pivot table change and adjust the chart&#8217;s series data accordingly, but that&#8217;s probably beyond the scope of any blog post.</p>
<p>However, a pivot chart doesn&#8217;t let you add data from outside the pivot table, or exclude data from the pivot table (though you could format a series to make it invisible).</p>
<p>In Excel 2003, you cannot change the size of the plot area or the position of the legend, chart title, or axis titles (other than deleting them). You can remove the pivot field buttons (Pivot Table toolbar &gt; PivotChart dropdown &gt; Hide PivotChart Field Buttons) to gain a little space, but you still can&#8217;t move or resize the chart elements.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://peltiertech.com/WordPress/wp-content/img200806/PCht_bydatecountry_nolabels.png" alt="Pivot Chart by Date and by Country without Pivot Field Buttons" /></p>
<p>Excel 2007 doesn&#8217;t have the Field Buttons cluttering up the chart. Instead there is a floating PivotChart Filter Pane that, together with the PivotTable Field List, serves the same function less intrusively. Excel 2007 also allows you to move or resize the individual chart elements. But the other inflexible features of pivot charts remain.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://peltiertech.com/WordPress/wp-content/img200806/PCht_bydatecountry_2007.png" alt="Pivot Chart by Date and by Country in Excel 2007" /></p>
<p>So you decide you need a regular chart to regain your formatting and source data flexibility.</p>
<p>Making a regular chart is actually easier than you think, as long as you are careful about setting the chart series data. You cannot set the overall source data range for the chart. You have to start with a blank chart, and add your data one series at a time.</p>
<p>Here is the protocol for creating a regular chart similar to the pivot chart above, using the pivot table&#8217;s data.</p>
<ol>
<li>Select a blank cell which is not touching the pivot table.</li>
<li>Insert a chart. In Excel 2003, go to Insert menu &gt; Chart, and select a chart type and subtype in step 1 of the Chart Wizard, and click Finish. In Excel 2007, simply select a chart type from the Insert tab, then choose the desired subtype.</li>
<li>Right click the chart, choose Source Data or Select Data. In Excel 2003, click on the Series tab.</li>
<li>Click the Add button to add a new series.</li>
<li>Click in the Series Name box, and then select the cell with the series name (e.g., the country label UK).</li>
<li>Click in the Values, Y Values, or Series Values box, then select the range containing the Y values (the Order Amount data under the UK label(.</li>
<li>In Excel 2003, click in the Category (X) Axis Labels or X Values box, then select the range containing the category labels; In Excel 2007, click Edit under Horizontal (Category) Axis Labels, then select the range containing these labels. In both cases, this is the two-column range between the Years and Order Date field buttons at the top and the Grand Total label at the bottom.</li>
<li>Repeat steps 4 through 7 as required for all series, including data inside and outside the pivot table.</li>
</ol>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://peltiertech.com/WordPress/wp-content/img200806/Cht_bydatecountry.png" alt="Regular Chart by Date and by Country" /></p>
<p>If I have other data for a country not included in the pivot table, I can simply add it to a regular chart per the protocol above. A pivot chart allows no outside data.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://peltiertech.com/WordPress/wp-content/img200806/Cht_bydatecountry3.png" alt="Regular Chart by Date and by Country" /></p>
<p>If I want an XY chart, I can create a regular XY chart using the protocol above. A pivot chart cannot use the XY chart type, nor can it use a date-scale axis in a line chart.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://peltiertech.com/WordPress/wp-content/img200806/Cht_XYcountries.png" alt="Regular XY Chart comparing Countries" /></p>
]]></content:encoded>
			<wfw:commentRss>http://peltiertech.com/WordPress/regular-charts-from-pivot-tables/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Grouping by Date in a Pivot Table</title>
		<link>http://peltiertech.com/WordPress/grouping-by-date-in-a-pivot-table/</link>
		<comments>http://peltiertech.com/WordPress/grouping-by-date-in-a-pivot-table/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 04:20:47 +0000</pubDate>
		<dc:creator>Jon Peltier</dc:creator>
				<category><![CDATA[Pivot Tables]]></category>
		<category><![CDATA[group data]]></category>
		<category><![CDATA[pivot chart]]></category>

		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=113</guid>
		<description><![CDATA[You can add flexibility to your data analysis by grouping variables. For example, you may have daily sales figures that fluctuate greatly in value, some days having no sales at all, some days with small values, and some with large values. A plot of this data is very noisy, and it&#8217;s hard to see any [...]]]></description>
			<content:encoded><![CDATA[<p>You can add flexibility to your data analysis by grouping variables. For example, you may have daily sales figures that fluctuate greatly in value, some days having no sales at all, some days with small values, and some with large values. A plot of this data is very noisy, and it&#8217;s hard to see any patterns.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://peltiertech.com/WordPress/wp-content/img200806/Cht_bydate.png" alt="Plot by Date" width="447" height="234" /></p>
<p>In a pivot table, you can group dates by various measures ranging from seconds to years, to get a clearer view of the data. Plotting by month will smooth out the noise of a daily plot.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://peltiertech.com/WordPress/wp-content/img200806/Cht_bydate_grp1.png" alt="Plot by Month" width="447" height="234" /></p>
<p>You can combine groupings, for example, to compare monthly sales by year.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://peltiertech.com/WordPress/wp-content/img200806/Cht_bydate_grp2.png" alt="Plot by Month by Year" width="447" height="234" /></p>
<p><span id="more-113"></span></p>
<blockquote><p>These plots are regular charts which use pivot table data as their source. This technique will be covered in a (near) future post. The charts below are the corresponding pivot charts.</p></blockquote>
<p>Microsoft hosts a number of decent Pivot Table examples. I will use one of them for this tutorial. Go to the Microsoft example <a href="http://office.microsoft.com/en-gb/excel/HA010346331033.aspx" rel="nofollow" class="vt-p" >25 easy PivotTable reports</a>, which has a link to <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=5E720455-FD3F-47BB-96BF-94819AA214C4&amp;displaylang=en" rel="nofollow" class="vt-p" >Excel 2002 Sample: PivotTable Reports</a>. From this page you can download a self-extracting executable named <tt class="tt">Reports.exe</tt>, which contains four workbooks. The top few records of the <tt class="tt">Source Data</tt> worksheet of the <tt class="tt">SampleSalespersonReports.xls</tt> workbook looks like this:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://peltiertech.com/WordPress/wp-content/img200806/PT_sourcedata.png" alt="Pivot Table Source Data" width="363" height="351" /></p>
<p>To create a pivot table, select one cell within this data range, and choose <tt class="tt">Pivot Table and Pivot Chart Report</tt> from the Data menu. To keep things uncomplicated, place the pivot table onto a new worksheet. Drag the <tt class="tt">Order Date</tt> field to the rows area and the <tt class="tt">Order Amount</tt> field to the Data area. The top few rows of the pivot table looks like this:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://peltiertech.com/WordPress/wp-content/img200806/PT_bydate.png" alt="Pivot Table by Date" width="181" height="337" /></p>
<p>Click in this pivot table and click the chart wizard button. The resulting pivot chart looks like this when it is relocated to the worksheet:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://peltiertech.com/WordPress/wp-content/img200806/PCht_bydate.png" alt="Pivot Chart by Date" width="447" height="268" /></p>
<p>To group the dates, right click anywhere in the date field range, choose <tt class="tt">Group and Show Detail</tt>, then choose <tt class="tt">Group</tt>.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://peltiertech.com/WordPress/wp-content/img200806/GroupMenus.png" alt="Group Context Menus" width="363" height="324" /></p>
<p>To group by any time period, select that period in the dialog. To group by weeks, select <tt class="tt">Days</tt>, and change Number of Days to 7. To group by month, choose <tt class="tt">Months</tt>; note that this grouping will combine data for each month regardless of year. In this example, group by both <tt class="tt">Months</tt> and <tt class="tt">Years</tt>.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://peltiertech.com/WordPress/wp-content/img200806/GroupDialog.png" alt="Group Dialog" width="234" height="273" /></p>
<p>The Order Date column of the pivot table is split into a Years and a Months column.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://peltiertech.com/WordPress/wp-content/img200806/PT_bydate_grp1.png" alt="Pivot Table by Month" width="258" height="351" /></p>
<p>With the new grouping of months and years, the pivot chart changes to plot months and years along the category axis.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://peltiertech.com/WordPress/wp-content/img200806/PCht_bydate_grp1.png" alt="Pivot Chart by Month" width="447" height="268" /></p>
<p>Click on the Years field button, and drag it to the columns area, where the Total label is located. This splits the data into three yearly columns, each showing monthly totals for the respective year.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://peltiertech.com/WordPress/wp-content/img200806/PT_bydate_grp2.png" alt="Pivot Table by Month and by Year" width="364" height="211" /></p>
<p>The pivot chart now shows one series of monthly sales for each year.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://peltiertech.com/WordPress/wp-content/img200806/PCht_bydate_grp2.png" alt="Pivot Chart by Month by Year" width="447" height="268" /></p>
<p>The dynamic nature of this pivot chart illustrates one of the benefits of pivot charts: the chart continues to display the data no matter how the table is pivoted. This makes pivot charts indispensable during the early stages of data exploration. The pivot chart&#8217;s relative inflexibility when it comes to formatting and handling of arbitrary (non-pivot-related) data, make pivot charts a liability during later stages of data presentation.</p>
<p>In an upcoming blog entry, I&#8217;ll describe how to create regular charts like those in the beginning of this article using data from a pivot table.</p>
<p><strong>For more about pivot tables, check out these pages on my web site:</strong></p>
<ul>
<li><a href="http://peltiertech.com/Excel/Pivots/pivotstart.htm" rel="nofollow" class="vt-p" ><strong>Pivot Tables and Pivot Charts</strong></a><br />
- Contributed by fellow Excel MVP Debra Dalgleish. Check out Debra’s <a href="http://www.contextures.com/tiptech.html" rel="nofollow" class="vt-p"  target="_blank">Excel Tips page</a><br />
- <a href="http://peltiertech.com/Excel/Pivots/pivottables.htm" rel="nofollow" class="vt-p" >Introduction to Pivot Tables in Excel</a><br />
- <a href="http://peltiertech.com/Excel/Pivots/pivotcharts.htm" rel="nofollow" class="vt-p" >Working with Pivot Charts in Excel</a><br />
- <a href="http://peltiertech.com/Excel/Pivots/pivotvba.htm" rel="nofollow" class="vt-p" >Pivot Table Programming</a><br />
- <a href="http://peltiertech.com/Excel/Pivots/pivotlinks.htm" rel="nofollow" class="vt-p" >Pivot Table and Pivot Chart Links</a></li>
<li><a href="http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=553" rel="nofollow" class="vt-p" >Pivot Tables, Pivot Charts, and Real Charts</a> <em>(TechTrax Article)</em></li>
<li><strong>Pivot Table Articles on the Peltier Tech Blog</strong></li>
<li> &#8211; <a href="http://peltiertech.com/WordPress/explore-your-data-with-pivot-tables/"class="vt-p" title="Explore Your Data With Pivot Tables | Peltier Tech Blog" >Explore Your Data With Pivot Tables</a><br />
- <a href="http://peltiertech.com/WordPress/preliminary-data-exploration-with-excel-pivot-tables/"class="vt-p" title="Preliminary Data Exploration with Excel Pivot Tables | Peltier Tech Blog" >Preliminary Data Exploration with Excel Pivot Tables</a><br />
- <a href="http://peltiertech.com/WordPress/regular-charts-from-pivot-tables/"class="vt-p" title="Making Regular Charts from Pivot Tables | Peltier Tech Blog" >Making Regular Charts from Pivot Tables</a><br />
- <a href="http://peltiertech.com/WordPress/update-regular-chart-when-pivot-table-updates/"class="vt-p" title="Update Regular Chart when Pivot Table Updates | Peltier Tech Blog" >Update Regular Chart when Pivot Table Updates</a><br />
- <a href="http://peltiertech.com/WordPress/using-pivot-table-data-for-a-chart-with-a-dual-category-axis/"class="vt-p" title="Using Pivot Table Data for a Chart with a Dual Category Axis | Peltier Tech Blog" >Using Pivot Table Data for a Chart with a Dual Category Axis</a><br />
- <a href="http://peltiertech.com/WordPress/grouping-by-date-in-a-pivot-table/"class="vt-p" title="Grouping by Date in a Pivot Table | Peltier Tech Blog" >Grouping by Date in a Pivot Table</a><br />
- <a href="http://peltiertech.com/WordPress/referencing-pivot-table-ranges-in-vba/"class="vt-p" title="Referencing Pivot Table Ranges in VBA | Peltier Tech Blog" >Referencing Pivot Table Ranges in VBA</a><br />
- <a href="http://peltiertech.com/WordPress/copy-pivot-table-pivot-chart-link-to-new-data/"class="vt-p" title="Copy a Pivot Table and Pivot Chart and Link to New Data | Peltier Tech Blog" >Copy a Pivot Table and Pivot Chart and Link to New Data</a><br />
- <a href="http://peltiertech.com/WordPress/pivot-table-conditional-formatting-with-vba/"class="vt-p" title="Pivot Table Conditional Formatting with VBA | Peltier Tech Blog" >Pivot Table Conditional Formatting with VBA</a><br />
- <a href="http://peltiertech.com/WordPress/dynamic-chart-using-pivot-table-and-range-names/"class="vt-p" title="Dynamic Chart using Pivot Table and Range Names | Peltier Tech Blog" >Dynamic Chart using Pivot Table and Range Names</a><br />
- <a href="http://peltiertech.com/WordPress/dynamic-chart-using-pivot-table-and-vba/"class="vt-p" title="Dynamic Chart using Pivot Table and VBA | Peltier Tech Blog" >Dynamic Chart using Pivot Table and VBA</a></li>
<li><a href="http://peltiertech.com/Excel/xlbooks.html#PTAnalysis" rel="nofollow" class="vt-p" >Books on Excel Pivot Tables</a><br />
- <a href="http://www.amazon.com/gp/redirect.html%3FASIN=1590596293%26tag=peltiertechni-20%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Excel-Pivot-Tables-Recipe-Book/dp/1590596293%253FSubscriptionId=02E5W5871AJF7PMMMS82" rel="nofollow" class="vt-p" >Excel Pivot Tables Recipe Book: A Problem-Solution Approach</a> by Debra Dalgleish<br />
- <a href="http://www.amazon.com/gp/redirect.html%3FASIN=1590598903%26tag=peltiertechni-20%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Beginning-PivotTables-Excel-2007-Professional/dp/1590598903%253FSubscriptionId=02E5W5871AJF7PMMMS82" rel="nofollow" class="vt-p" >Beginning PivotTables in Excel 2007: From Novice to Professional</a> by Debra Dalgleish<br />
- <a href="http://www.amazon.com/gp/redirect.html%3FASIN=0789734354%26tag=peltiertechni-20%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Pivot-Table-Crunching-Business-Solutions/dp/0789734354%253FSubscriptionId=02E5W5871AJF7PMMMS82" rel="nofollow" class="vt-p" >Pivot Table Data Crunching</a> by Bill Jelen and Michael Alexander<br />
- <a href="http://www.amazon.com/gp/redirect.html%3FASIN=0789736012%26tag=peltiertechni-20%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Crunching-Microsoft-Office-Business-Solutions/dp/0789736012%253FSubscriptionId=02E5W5871AJF7PMMMS82" rel="nofollow" class="vt-p" >Pivot Table Data Crunching for Microsoft Office Excel 2007</a> by Bill Jelen and Michael Alexander</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://peltiertech.com/WordPress/grouping-by-date-in-a-pivot-table/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Using Pivot Table Data for a Chart with a Dual Category Axis</title>
		<link>http://peltiertech.com/WordPress/using-pivot-table-data-for-a-chart-with-a-dual-category-axis/</link>
		<comments>http://peltiertech.com/WordPress/using-pivot-table-data-for-a-chart-with-a-dual-category-axis/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 15:53:42 +0000</pubDate>
		<dc:creator>Jon Peltier</dc:creator>
				<category><![CDATA[Pivot Tables]]></category>
		<category><![CDATA[pareto]]></category>

		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=60</guid>
		<description><![CDATA[Tony commented on the previous post, Chart with a Dual Category Axis, asking whether I&#8217;d use a pareto chart for this data. I commented that it almost was a pareto chart, since at least within each category the data is sorted from high to low. Then I got to thinking, if I put my data [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.supportanalytics.com/blog" rel="nofollow" >Tony</a> commented on the previous post, <a href="http://peltiertech.com/WordPress/chart-with-a-dual-category-axis/">Chart with a Dual Category Axis</a>, asking whether I&#8217;d use a pareto chart for this data. I commented that it almost was a pareto chart, since at least within each category the data is sorted from high to low. Then I got to thinking, if I put my data into a table, and use a pivot table to sort both the main category and sub category by number of defects, I would essentially have a pareto chart.</p>
<blockquote><p>A <a href="http://en.wikipedia.org/wiki/Pareto_chart" rel="nofollow" >pareto</a> <a href="http://www.spcforexcel.com/paretodiagram.htm" rel="nofollow" >chart</a> is a column or bar chart that lists items in decreasing order of their occurrence. A pareto chart may include a line chart series showing the cumulative occurrence of the items. The left-most items are most prevalent, so if your pareto chart shows instances of failure modes, you start fixing the left-most failure modes first.</p>
</blockquote>
<p><span id="more-60"></span>Here is my data table. The main category data from the first column is duplicated in the second for reasons which will become clear when you try to use the category in two places in the pivot table.</p>
<p>&nbsp;</p>
<table style="font-family: Arial, sans-serif; font-size=10pt;" border="1" cellspacing="0" cellpadding="2" align="center" bgcolor="#ffffff" bordercolor="#c0c0c0">
<tbody>
<tr>
<td width="28" align="center" bgcolor="#cccccc"></td>
<td width="128" align="center" bgcolor="#cccccc"><strong>A</strong></td>
<td width="96" align="center" bgcolor="#cccccc"><strong>B</strong></td>
<td width="128" align="center" bgcolor="#cccccc"><strong>C</strong></td>
<td width="64" align="center" bgcolor="#cccccc"><strong>D</strong></td>
</tr>
<tr>
<td align="center" bgcolor="#cccccc"><strong>1</strong></td>
<td align="left"><strong>Main Category</strong></td>
<td align="left"><strong>Category</strong></td>
<td align="left"><strong>Sub Category</strong></td>
<td align="left"><strong>Defects</strong></td>
</tr>
<tr>
<td align="center" bgcolor="#cccccc"><strong>2</strong></td>
<td align="left">Mechanical</td>
<td align="left">Mechanical</td>
<td align="left">Gear</td>
<td align="right">11</td>
</tr>
<tr>
<td align="center" bgcolor="#cccccc"><strong>3</strong></td>
<td align="left">Mechanical</td>
<td align="left">Mechanical</td>
<td align="left">Bearing</td>
<td align="right">8</td>
</tr>
<tr>
<td align="center" bgcolor="#cccccc"><strong>4</strong></td>
<td align="left">Mechanical</td>
<td align="left">Mechanical</td>
<td align="left">Motor</td>
<td align="right">3</td>
</tr>
<tr>
<td align="center" bgcolor="#cccccc"><strong>5</strong></td>
<td align="left">Electrical</td>
<td align="left">Electrical</td>
<td align="left">Switch</td>
<td align="right">19</td>
</tr>
<tr>
<td align="center" bgcolor="#cccccc"><strong>6</strong></td>
<td align="left">Electrical</td>
<td align="left">Electrical</td>
<td align="left">Plug</td>
<td align="right">12</td>
</tr>
<tr>
<td align="center" bgcolor="#cccccc"><strong>7</strong></td>
<td align="left">Electrical</td>
<td align="left">Electrical</td>
<td align="left">Cord</td>
<td align="right">11</td>
</tr>
<tr>
<td align="center" bgcolor="#cccccc"><strong>8</strong></td>
<td align="left">Electrical</td>
<td align="left">Electrical</td>
<td align="left">Fuse</td>
<td align="right">3</td>
</tr>
<tr>
<td align="center" bgcolor="#cccccc"><strong>9</strong></td>
<td align="left">Electrical</td>
<td align="left">Electrical</td>
<td align="left">Bulb</td>
<td align="right">2</td>
</tr>
<tr>
<td align="center" bgcolor="#cccccc"><strong>10</strong></td>
<td align="left">Hydraulic</td>
<td align="left">Hydraulic</td>
<td align="left">Pump</td>
<td align="right">4</td>
</tr>
<tr>
<td align="center" bgcolor="#cccccc"><strong>11</strong></td>
<td align="left">Hydraulic</td>
<td align="left">Hydraulic</td>
<td align="left">Leak</td>
<td align="right">3</td>
</tr>
<tr>
<td align="center" bgcolor="#cccccc"><strong>12</strong></td>
<td align="left">Hydraulic</td>
<td align="left">Hydraulic</td>
<td align="left">Seals</td>
<td align="right">1</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>Select the data and insert a pivot table. Put the Main Category and Sub Category fields into the rows area, the Category field into the columns area, and the Defects field (Sum of Defects) into the data area.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><img style="border: 0pt none;" src="http://peltiertech.com/WordPress/wp-content/img200804/PivotTableForDualCategoryAxis.png" alt="Pivot Table" width="419" height="222" /></p>
<p>This data arrangement looks very much like what I set up manually in the last post. Now you can either make a pivot chart from the data:</p>
<p style="text-align: center;"><img style="border: 0pt none;" src="http://peltiertech.com/WordPress/wp-content/img200804/PvtCht1DualCatColumn.png" alt="Dual Category Axis Pivot Chart" width="568" height="357" /></p>
<p>which is somewhat inflexible in its formatting. I personally would like to remove some of the white space all around the chart and delete the legend. You can clean it up somewhat by hiding the pivot chart field buttons:</p>
<p style="text-align: center;"><img style="border: 0pt none;" src="http://peltiertech.com/WordPress/wp-content/img200804/PvtCht2DualCatColumn.png" alt="Pivot Chart with Dual Category Axis" width="568" height="289" /></p>
<p>I still like to make a regular chart from my pivot data, as long as the pivot table isn&#8217;t going to change its shape too much. To do this, you have to select a blank cell distant from the pivot table when you insert the chart. Then you need to add each series individually and select its data, in Classic Excel either in step 2 of the Chart Wizard or in the Source Data dialog (use the Series tab in both cases), or in Excel 2007 using the Select Data command.</p>
<p style="text-align: center;"><img style="border: 0pt none;" src="http://peltiertech.com/WordPress/wp-content/img200804/PvtTblDualCatColumn.png" alt="Regular Dual Cat Axis Chart from Pivot Table Data" width="512" height="289" /></p>
<p>The advantage of the regular chart is that you have full control over all formatting, and over the data used in the chart. The disadvantage is that if the pivot data changes and the pivot table is refreshed or repivoted, the pivot table may cover a different range, and the chart will plot the original range. If the data changes a lot, you will have to (a) update the chart source data links manually, (b) design some clever dynamic range definitions so the links automatically keep pointing to the correct range, or (c) write a VBA procedure to update the chart&#8217;s links. This last option is pretty tricky to set up, but saves lots of time and frustration in the long run.</p>
<p><strong><em>Second in a series</em></strong></p>
<ul>
<li><a href="http://peltiertech.com/WordPress/chart-with-a-dual-category-axis/">Chart with a Dual Category Axis</a></li>
<li>Using Pivot Table Data for a Chart with a Dual Category Axis</li>
<li><a href="http://peltiertech.com/WordPress/dynamic-chart-using-pivot-table-and-range-names/">Dynamic Chart using Pivot Table and Range Names</a></li>
<li><a href="http://peltiertech.com/WordPress/dynamic-chart-using-pivot-table-and-vba/">Dynamic Chart using Pivot Table and VBA</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://peltiertech.com/WordPress/using-pivot-table-data-for-a-chart-with-a-dual-category-axis/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

