<?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>8020world Management Consulting &#187; Software</title>
	<atom:link href="http://8020world.com/category/geeky-stuff/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://8020world.com</link>
	<description>Game Theory &#124; Wargaming &#124; Strategy &#124; Modeling &#124; System Dynamics</description>
	<lastBuildDate>Fri, 27 Jan 2012 06:06:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Normalize Excel tables</title>
		<link>http://8020world.com/2006/11/normalize-excel-tables/</link>
		<comments>http://8020world.com/2006/11/normalize-excel-tables/#comments</comments>
		<pubDate>Thu, 30 Nov 2006 03:51:16 +0000</pubDate>
		<dc:creator>Juan-Carlos Méndez García</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Data analysis]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tools & methodologies]]></category>

		<guid isPermaLink="false">http://jcandkimmita.info/jc/?p=58</guid>
		<description><![CDATA[Business data is quite often expressed across many dimensions. The profitability equation in a company is very simple in concept, but in practice those revenues come across regions, product lines, products etc., making them in fact multidimensional data. Users of &#8230; <a href="http://8020world.com/2006/11/normalize-excel-tables/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Business data is quite often expressed across many dimensions.  The profitability equation in a company is very simple in concept, but in practice those revenues come across regions, product lines, products etc., making them in fact multidimensional data.</p>
<p>Users of <a href="http://en.wikipedia.org/wiki/Olap">OLAP systems</a> are very aware of multidimensional data.  However, many spreadsheet users are not, so they manage to flatten the data the best they can, using pages or subtotals for dimensions beyond the second one.</p>
<p>Modern spreadsheets have &#8220;PivotTable&#8221; capabilities, which makes easier to deal with multidimensional data.  To feed these pivot tables, the information has to be normalized.  This post explains how to normalize data from non-normal representation, using a Visual Basic macro</p>
<p>If you are familiar with OLAP and normalized data, skip to the code.  I&#8217;ll show samples of non-normalized data, how the same data would look normalized, and why this recipe is useful.</p>
<p><span id="more-58"></span></p>
<p>Very often people provide me with data on Excel sheets that I need to analyze across different &#8220;breakdown dimensions&#8221;.  The specific workbooks I receive usually have several worksheets with similar structures (for instance, one per country).  Within the worksheet there are usually several tables with similar structure, too, which add together.  Easier to show with an example:</p>
<p><img src="/jc/wp-content/media/table1.png?84cd58" alt='Pivot Example - Table 1'  width="60%" height="60%"/></p>
<p>The numbers show a quantity (let&#8217;s say production) for products in a given platform, for different years.  When a new year is needed, the tables are extended to the right, and new products are added in new lines as needed.  Each table shows products belonging to a platform (or produced in a plant, or whatever).  Now, let&#8217;s assume there are several countries.  Typically, the Excel user just replicates the structure in another sheet and has one sheet per country.  Quick and easy.</p>
<p>When analysis is required, things become harder.  Usually formulas are added at the end of rows and columns to sum up.  Sometimes, a &#8220;dimension&#8221; is worked out having subtotal rows.  SUM ranges now become of different lengths depending on the number of rows in the subrange.  Spreadsheets become error prone and hard to maintain because the data and the formulas are not separated.   If 10 new products are added across several categories, the spreadsheet user will have to go inserting rows, expended formulas, etc.  Some clever users add formulas in the corners of the table that compare the sum of rows with the sum of columns to make sure no formula was left improperly expended.  Sounds familiar?</p>
<p>All the grief in maintaining those sheets can be avoided using PivotTables.  There are <a href="http://www.google.com.br/search?q=excel+pivottable+tutorial">many tutorials on PivotTables</a>  out there, so I won&#8217;t go into repeating it.  Believe me&#8230; if the scenario depicted above is familiar to you and you are not using pivottables, make yourself a favor and read the tutorials.  The two images below give an idea of the reports that the PivotTable tool will make for you.  Need a report looking somhow different or with a different &#8220;cut&#8221; of the data?  You can have hundreds of them linked to the same data and they will update automagically when you add data.  New years?  No problem&#8230; as soon as some data element refers say, to 2009 in the example, each PivotTable you had will extend in the appropriate dimension to include this year. </p>
<p><img src="/jc/wp-content/media/table3.png?84cd58" alt='Pivot Example - Table 3'  width="60%" height="60%"/></p>
<p><img src="/jc/wp-content/media/table4.png?84cd58" alt='Pivot Example - Table 4'  width="60%" height="60%"/></p>
<p>The only problem, is that to use PivotTables, the information </p>
<p><img src="/jc/wp-content/media/table2.png?84cd58" alt='Pivot Example - Table 2'  width="60%" height="60%"/></p>
<pre lang="vb">
Sub normalize()
' Takes a matrix with names in rows and columns and turns it into a
' normalized version.
' Names for rows and columns are expected to be outside the selection
' Cell {-1,-1} is an attribute to be repeated in all entries
' Spreadsheet name is an attribute to be repeated in all entries
' Will modify the row and column structure of the spreadsheet
' Will overwrite anyting in the destination area
' Will not check if there is enough space on the spreadsheet

    Dim ss As Range
    Dim rr As Integer, cc As Integer
    Dim startRow As Integer, startCol As Integer
    Set ss = Selection

    rr = ss.Rows.Count
    cc = ss.Columns.Count

    If rr < 2 Then GoTo normalize_done
    If cc < 2 Then GoTo normalize_done

    startRow = ss.Row
    startCol = ss.Column

    If startRow < 2 Then GoTo normalize_done
    If startCol < 2 Then GoTo normalize_done

    ' Copy all the data transposed into rows
    For ci = 2 To cc
        Application.Intersect(ss, Columns(startCol + ci - 1)).Copy
        Cells(startRow + rr * (ci - 1), startCol).PasteSpecial xlPasteValues
    Next ci

    ' Copy the row names in all the transposed rows
    Range(Cells(startRow, startCol - 1), Cells(startRow + rr - 1, startCol - 1)).Copy
    Range(Cells(startRow + rr, startCol - 1), Cells(startRow + rr * cc - 1, startCol - 1)).PasteSpecial xlPasteValues

    Dim v As String
    v = ActiveSheet.Name
    ' Copy the column names, matrix name and sheet name in each of the rows
    For ci = 1 To cc
        Cells(startRow - 1, startCol + ci - 1).Copy
        Range(Cells(startRow + rr * (ci - 1), startCol + cc), _
            Cells(startRow + rr * ci - 1, startCol + cc)).PasteSpecial xlPasteValues
        Cells(startRow - 1, startCol - 1).Copy
        Range(Cells(startRow + rr * (ci - 1), startCol + cc + 1), _
            Cells(startRow + rr * ci - 1, startCol + cc + 1)).PasteSpecial xlPasteValues
        Range(Cells(startRow + rr * (ci - 1), startCol + cc + 2), _
            Cells(startRow + rr * ci - 1, startCol + cc + 2)).Value = v
    Next ci

    ' Move the last columns back to be closer to the data and clean up
    Range(Cells(startRow, startCol + cc), _
            Cells(startRow + rr * cc - 1, startCol + cc + 2)).Cut _
            Destination:=Range(Cells(startRow, startCol + 1), _
            Cells(startRow + rr * cc - 1, startCol + 3))
    Range(Cells(startRow - 1, startCol + 4), _
            Cells(startRow + rr * cc - 1, startCol + cc + 2)).ClearContents
    Range(Cells(startRow, startCol - 1), _
            Cells(startRow + rr * cc - 1, startCol + 3)).Select
    Selection.Style = "Normal"
    Application.CutCopyMode = False
normalize_done:

End Sub
</pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://8020world.com/2006/11/normalize-excel-tables/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>XBRL reporting standard</title>
		<link>http://8020world.com/2006/05/xbrl-reporting-standard/</link>
		<comments>http://8020world.com/2006/05/xbrl-reporting-standard/#comments</comments>
		<pubDate>Tue, 23 May 2006 18:08:19 +0000</pubDate>
		<dc:creator>Juan-Carlos Méndez García</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://jcandkimmita.info/jc/?p=30</guid>
		<description><![CDATA[Here is a link to the XBRL standard for financial reporting. For the genetic algorithm project this may be the best alternative to read financial info]]></description>
			<content:encoded><![CDATA[<p>Here is a <a href="http://www.xbrl.org/CompanyReports/">link</a> to the XBRL standard for financial reporting.  For the genetic algorithm project this may be the best alternative to read financial info</p>
]]></content:encoded>
			<wfw:commentRss>http://8020world.com/2006/05/xbrl-reporting-standard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: basic
Object Caching 320/386 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: assets.8020world.com

Served from: 8020world.com @ 2012-02-09 13:59:21 -->
