<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
<title>Clearly and Simply</title>
<link>http://www.clearlyandsimply.com/clearly_and_simply/</link>
<description>Intelligent Data Analysis, Modeling, Simulation and Visualization</description>
<language>en-US</language>
<lastBuildDate>Thu, 02 Feb 2012 21:00:00 +0100</lastBuildDate>
<generator>http://www.typepad.com/</generator>

<docs>http://www.rssboard.org/rss-specification</docs>
<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ClearlyAndSimply" /><feedburner:info uri="clearlyandsimply" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license><image><link>http://creativecommons.org/licenses/by-nc-sa/3.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image><feedburner:emailServiceId>ClearlyAndSimply</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
<title>6 Famous Paintings in Tableau</title>
<link>http://feedproxy.google.com/~r/ClearlyAndSimply/~3/2F_GVKIaFYs/6-famous-paintings-in-tableau.html</link>
<guid isPermaLink="false">http://www.clearlyandsimply.com/clearly_and_simply/2012/02/6-famous-paintings-in-tableau.html</guid>
<description>Visualize 6 world famous paintings with Tableau Software</description>
<content:encoded><![CDATA[<h3><strong>Visualize 6 world famous paintings with Tableau Software</strong></h3>
<p><a href="http://www.flickr.com/photos/thomasbrauner/977291987/" title="© Songkran / flickr.com"><img align="left" alt="© Songkran / flickr.com" border="0" height="260" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330168e6922e5a970c-pi" style="background-image: none; margin: 0px 15px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; padding-top: 0px; border-width: 0px;" title="© Songkran / flickr.com" width="202" /></a>It has been a very long time since the last post here on <a href="http://www.clearlyandsimply.com" title="Clearly and Simply">Clearly and Simply</a>: the start of a guest post series by Sheel Bhatiani about how to <a href="http://www.clearlyandsimply.com/clearly_and_simply/2011/11/dynamic-sorting-with-tableau.html" title="Dynamic Sorting with Tableau">Expand your reach in Tableau with Parameters</a>.</p>
<p>Ever since I was so snowed under with work that I wasn’t able to do the final editing and formatting of Sheel’s articles. I hope for your understanding.</p>
<p>I know that most of you are eagerly waiting for the guest series to be continued. Agreed, it is long overdue, but please bear with me, I can’t let this one go: Yesterday the Art Newspaper published that the <a href="http://www.theartnewspaper.com/articles/Earliest+copy+of+Mona+Lisa+found+in+Prado/25514" title="Earliest copy of Mona Lisa found in Prado">earliest copy of the Mona Lisa has been found at the Prado in Madrid, Spain</a>. Today, Darren Chalk over at <a href="http://www.thedatastudio.co.uk/" title="The Data Studio">The Data Studio</a> published the first article of a series of posts about <a href="http://www.thedatastudio.co.uk/blog/the-data-studio-blog/art-in-tableau-1" title="Art in Tableau">Art in Tableau</a>.</p>
<p>This reminded me of publicly available data sets to visualize famous paintings like van Gogh’s Self Portrait, Botticelli&#39;s The Birth of Venus and – you guessed it – Leonardo da Vinci&#39;s Mona Lisa.</p>
<p>Way back in June 2010, I already published an emulation of a piece of art using Tableau: <a href="http://www.clearlyandsimply.com/clearly_and_simply/2010/06/tableau-replica-of-curtis-steiners-1000-blocks.html" title="The Tableau Replica of Curtis Steiner’s 1,000 Blocks">The Tableau Replica of Curtis Steiner’s 1,000 Blocks</a> and – although totally useless for business applications – that post was very well received by my readers.</p>
<p>Thus, I just can’t let this opportunity slip through my fingers and I intersperse this little article before we will continue with Sheel’s next article.</p>


<h4><strong><span>6 Famous Paintings in Tableau</span></strong></h4>
<p>So, here are 6 famous paintings visualized with Tableau Software:</p>
<p><strong><span>Leonardo da Vinci’s Mona Lisa </span></strong></p>
<p><img alt="Leonardo da Vinci’s Mona Lisa " border="0" height="500" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330168e6922e72970c-pi" style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Leonardo da Vinci’s Mona Lisa " width="495" /></p>
<p><strong><span>Jan Vermeer&#39;s Girl with a Pearl Earring </span></strong></p>
<p><img alt="Jan Vermeer&#39;s Girl with a Pearl Earring" border="0" height="500" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330163009b3f2d970d-pi" style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Jan Vermeer&#39;s Girl with a Pearl Earring" width="495" /></p>
<p><strong><span>Sandro Botticelli&#39;s The Birth of Venus </span></strong></p>
<p><img alt="Sandro Botticelli&#39;s The Birth of Venus" border="0" height="500" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330163009b3f43970d-pi" style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Sandro Botticelli&#39;s The Birth of Venus" width="495" /></p>
<p><strong><span>Vincent van Gogh&#39;s Self Portrait 1889 </span></strong></p>
<p><img alt="Vincent van Gogh&#39;s Self Portrait 1889" border="0" height="500" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330168e6922ea6970c-pi" style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Vincent van Gogh&#39;s Self Portrait 1889" width="495" /></p>
<p><strong><span>Diego Rodríguez de Silva y Velázquez’s Juan de Pareja </span></strong></p>
<p><img alt="Diego Rodríguez de Silva y Velázquez’s Juan de Pareja" border="0" height="500" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330168e6922ec6970c-pi" style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Diego Rodríguez de Silva y Velázquez’s Juan de Pareja" width="495" /></p>
<p><strong><span>Gustave Courbet&#39;s The Desperate Man </span></strong></p>
<p><img alt="Gustave Courbet&#39;s The Desperate Man" border="0" height="500" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb99883301676190f796970b-pi" style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Gustave Courbet&#39;s The Desperate Man" width="495" /></p>
<h4><strong><span>The Tableau Workbook</span></strong></h4>
<p>Unfortunately I cannot provide the workbook on Tableau Public, since Public is limited to 100,000 data rows. The data sets for all 6 paintings, however, are exactly 900,000 rows. Thus, I can only offer the screenshots above and the Tableau workbook for free download:</p>
<p style="text-align: center;"><a href="http://www.clearlyandsimply.com/clearly_and_simply/2012/02/6_famous_paintings.twbx" title="Download 6 Famous Paintings (Tableau Packaged Workbook, 2,146.6K)">Download 6 Famous Paintings (Tableau Packaged Workbook, 2,146.6K)</a></p>
<p>To open this workbook you need Tableau Desktop 7.0 (<a href="http://www.tableausoftware.com/products/desktop/try" title="Tableau Desktop Trial">trial version here</a>), <a href="http://www.tableausoftware.com/public/download" title="Tableau Public">Tableau Public</a> or the free <a href="http://www.tableausoftware.com/products/reader" title="Tableau Reader">Tableau Reader</a>.</p>
<p>Please be advised that Tableau needs a few seconds to render the data points of the view when opening the workbook or after you used the filter to switch to another painting.</p>
<h4><strong><span>The Technique</span></strong></h4>
<p>Not much to say here. The used visualization technique is as simple as can be:</p>
<ul>
<li>a XY scatter plot</li>
<li>a full circle as the shape</li>
<li>minimized size of the shape </li>
<li>fixed axes scales and hidden axes headers</li>
<li>a filter to let the user select one of the paintings</li>
<li>disable the “Show All Value” in the quick filter</li>
</ul>
<p>That’s it. As soon as you have your data ready, it takes less than 5 minutes to create this visualization.</p>
<h4><strong><span>The Data Source</span></strong></h4>
<p>The data sets are coming from a website called <a href="http://www.tsp.gatech.edu/index.html" title="Traveling Salesman Problem">Traveling Salesman Problem</a> run by the Georgia Tech. You can get tons of example data sets for the TSP there and – surprisingly enough – also the data sets of the 6 paintings used above. They refer to a painting as a Traveling Salesman Problem and they even have the results of the (so far) best routes visiting all data points.</p>
<p>Can you imagine? The shortest route through Mona Lisa? And you thought <strong>I</strong> would be a data geek!</p>
<h4><strong>What’s Next?</strong></h4>
<p>The next posts will continue Sheel Bhatiani’s guest post series <a href="http://www.clearlyandsimply.com/clearly_and_simply/2011/11/dynamic-sorting-with-tableau.html" title="Dynamic Sorting with Tableau">“Expand your reach in Tableau with Parameters”</a>. Sheel’s next article will come soon. At the same time I am also working on some new Excel workbooks and articles.</p>
<p>Please stay tuned.</p><img src="http://feeds.feedburner.com/~r/ClearlyAndSimply/~4/2F_GVKIaFYs" height="1" width="1"/>]]></content:encoded>


<category>Tableau</category>
<category>Visualization</category>

<dc:creator>Robert</dc:creator>
<pubDate>Thu, 02 Feb 2012 21:00:00 +0100</pubDate>

<feedburner:origLink>http://www.clearlyandsimply.com/clearly_and_simply/2012/02/6-famous-paintings-in-tableau.html</feedburner:origLink></item>
<item>
<title>Dynamic Sorting with Tableau</title>
<link>http://feedproxy.google.com/~r/ClearlyAndSimply/~3/XIJ2SJFjfWY/dynamic-sorting-with-tableau.html</link>
<guid isPermaLink="false">http://www.clearlyandsimply.com/clearly_and_simply/2011/11/dynamic-sorting-with-tableau.html</guid>
<description>How to add a dynamic, interactive sorting feature to your Tableau Dashboard. The first article of a guest post series on “Expand your reach in Tableau with Parameters”</description>
<content:encoded><![CDATA[<h3><strong><span>How to add a dynamic, interactive sorting feature to your Tableau Dashboard. </span><span>The first article of a guest post series on “Expand your reach in Tableau with Parameters”</span></strong></h3>
<p><em><a title="Sorting Oranges" href="http://www.flickr.com/photos/15416526@N06/3585717922/"><img style="background-image: none; margin: 0px 15px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; padding-top: 0px; border-width: 0px;" title="Sorting Oranges / Photographer: bighornplateau1 (flickr.com)" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330162fc54d965970d-pi" border="0" alt="Sorting Oranges / Photographer: bighornplateau1 (flickr.com)" width="260" height="179" align="left" /></a>To me, one of the most interesting sessions of this year’s Tableau Customer Conference was “Tips &amp; Tricks from the Wild”, where five Tableau champions presented some of their best techniques in Tableau. One of these exceptional Tableau experts is Sheel Bhatiani, Lead Software Developer at Cheyne Capital. I liked his tip so much that I asked if he would be so kind to share some of his tricks here on <a title="Clearly and Simply" href="http://www.clearlyandsimply.com">Clearly and Simply</a>. I am very happy to inform you that Sheel not only agreed to write one guest article here, but rather to publish a whole series of posts on how to “Expand your reach in Tableau with Parameters”. Sheel kicks off his series with today’s article. Enjoy.</em></p>
<p>Parameters - introduced with Tableau version 6 - are dynamic values that replace constants in calculations. They can be changed by the user of a dashboard or worksheet with an interactive control. This opens a lot of opportunities. Parameters in combination with Calculated Fields enable you to add a whole variety of additional interactivity to your Tableau workbook and dashboard. One of the most interesting things about Parameters is their ability to bring the existing Tableau built-features to the next level.</p>
<p>Today’s first article of my post series here shows the main concept of how to do this and includes a detailed tutorial how to use this for implementing a user-friendly interactive control to change the sort measure and the sort order of a view on a dashboard: Dynamic sorting with Tableau at your fingertips.</p>
<p>Are you ready to expand your reach in Tableau with Parameters? Here you go.</p>
<p>

</p>
<h4><strong><span>The Background and the Idea</span></strong></h4>
<p>Let’s take the Superstore Sales sample data coming with each Tableau installation and create a very simple view like this:</p>
<p><a href="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833015436d30f21970c-pi"><img style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="Superstore Sales View unsorted - click to enlarge" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833015436d30f29970c-pi" border="0" alt="Superstore Sales View unsorted - click to enlarge" width="520" height="311" /></a>A list of Customer States visualizing Net Profit and Sales with simple bar charts and Profit per Customer with a color coded tornado chart. You certainly know how to do this. Using the Multiple Marks feature, you put [Customer Name] on the Level of Detail Shelf and [Profit] on the Color Shelf for the tornado. No big deal.</p>
<p>Very often, analyzing data starts with sorting by different measures. And of course, Tableau provides different built-in ways of sorting your views: the one-click-sort using the sort buttons on a worksheet or dashboard or the persistent sort which allows you to sort by data sort order, alphabetic, by field or manually. However, sometimes the built-in features just ain’t enough.</p>
<p>The easiest way is selecting one measure by clicking on the axis (e.g. Net Profit) and then using the sort buttons on the Tableau toolbar. This works well for all three bar charts. However, sorting by Profit per Customer will sort the States by the total net profits. In other words, it will result in the same sort order as sorting by Net Profit. This works as designed, but what if you want to sort the view by profits only or losses only? Something like this:</p>
<p><a href="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833015436d30f30970c-pi"><img style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="Superstore Sales View sorted - click to enlarge" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833015436d30f39970c-pi" border="0" alt="Superstore Sales View sorted - click to enlarge" width="520" height="310" /></a>Of course this is possible with Tableau in general.</p>
<p>First, you need two simple Calculated Fields:</p>
<p>[Profits only] : <em>MAX([Profit],0)</em></p>
<p>and</p>
<p>[Losses only] : <em>MIN([Profit],0)</em></p>
<p>Finally you set the sort order of [Customer State] to <em>Sort by Field</em> and select either [Profits only] or [Losses only].</p>
<p>However, this is only possible on the worksheet, not on the dashboard. And it is inconvenient to change the sort measure and sort order of the view this way. Wouldn’t it be nice, if you would be able to change the sort measure and the sort order with a convenient and easy to access interactive control directly on the dashboard?</p>
<p>Parameters and some more Calculated Fields allow you to easily implement such an additional interactive sorting control.</p>
<p>Here is the detailed how-to tutorial:</p>
<h4><strong><span>The basic approach – A step-by-step tutorial</span></strong></h4>
<p>The basic approach needs only one Parameter and one Calculated Field for an interactive dynamic sort feature.</p>
<p><strong>Step 1: Create a Parameter</strong></p>
<p>Right click somewhere on the data window and select <em>Create Parameter</em>. In the following dialogue window, give the new Parameter a meaningful name like “Sort States by”, select <em>String</em> as the data type of the Parameter and enter names for all measures in the list of values table. Since we have only one Parameter to select both the sort measure and the sort order, you have to add two entries to the list for each sort measure and an additional description to represent the sort order. You could simply add “ascending” and “descending” to the measure names or – as shown in the following screenshot – you may also use symbols like triangles (triangle up for ascending, triangle down for descending):</p>
<p><a href="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330162fc54d97a970d-pi"><img style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="Parameter basic - click to enlarge" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833015436d30f55970c-pi" border="0" alt="Parameter basic - click to enlarge" width="260" height="234" /></a><strong>Step 2: Create a Calculated Field for the Sort Measure</strong></p>
<p>Next, right click again on the data window and create a new Calculated Field. The formula is a simple <em>CASE WHEN</em> statement. It evaluates the Parameter created in step 1 and assigns the according (i.e. user selected) measure to this Calculated Field. To switch from the default ascending to a descending sort order, we simply set the measure to its negative value.</p>
<p>The Calculated Field looks like this:</p>
<p><a href="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833015392ff809f970b-pi"><img style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="Calculated Field basic - click to enlarge" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330162fc54d993970d-pi" border="0" alt="Calculated Field basic - click to enlarge" width="320" height="279" /></a>Please be careful: the texts in this Calculated Field used after the <em>WHEN</em> statements have to be exactly the same as you defined them when creating the Parameter (see step 1).</p>
<p><strong>Step 3: Set the Sort Order of the dimension on the Row Shelf</strong></p>
<p>Click on the arrow of the [Customer State] pill on the Row Shelf and select <em>Sort</em>. In the following dialogue window, click on <em>Sort by Field</em> and select the Calculated Field created in step 2 ([State Sort Measure]):</p>
<p><a href="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330162fc54d99a970d-pi"><img style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="Sort basic - click to enlarge" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330162fc54d9a7970d-pi" border="0" alt="Sort basic - click to enlarge" width="244" height="260" /></a></p>
<p><strong>Step 4: Show Parameter Control</strong></p>
<p>Finally, right click on the Parameter [Sort States By] in the data window and select <em>Show Parameter Control</em>.</p>
<p>That’s it.</p>
<p>Only 4 steps and you have an additional drop down list to change the sort measure and sort order of your view in one go.</p>
<p>Here is the interactive version on Tableau Public:</p>



<script type="text/javascript" src="http://public.tableausoftware.com/javascripts/api/viz_v1.js"></script><div class="tableauPlaceholder" style="width:504px; height:769px;"><noscript><a href="#"><img alt="Dynamic Sort Dashboard - basic " src="http:&#47;&#47;public.tableausoftware.com&#47;static&#47;images&#47;dy&#47;dynamic_sort_basic&#47;DynamicSortDashboard&#47;1_rss.png" style="height: 100%; width: 100%; border: none" /></a></noscript><object class="tableauViz" width="504" height="769" style="display:none;"><param name="host_url" value="http%3A%2F%2Fpublic.tableausoftware.com%2F" /><param name="name" value="dynamic_sort_basic&#47;DynamicSortDashboard" /><param name="tabs" value="no" /><param name="toolbar" value="yes" /><param name="static_image" value="http:&#47;&#47;public.tableausoftware.com&#47;static&#47;images&#47;dy&#47;dynamic_sort_basic&#47;DynamicSortDashboard&#47;1.png" /><param name="animate_transition" value="yes" /><param name="display_static_image" value="yes" /><param name="display_spinner" value="yes" /><param name="display_overlay" value="yes" /></object></div><div style="width:504px;height:22px;padding:0px 10px 0px 0px;color:black;font:normal 8pt verdana,helvetica,arial,sans-serif;"><div style="float:right; padding-right:8px;"><a href="http://www.tableausoftware.com/public?ref=http://public.tableausoftware.com/views/dynamic_sort_basic/DynamicSortDashboard" target="_blank">Powered by Tableau</a></div></div>


<h4><strong><span>The enhanced version</span></strong></h4>
<p>The idea of the enhanced version is obvious: Instead of having two entries for each measure in the drop-down list of the Parameter, we add another Parameter to select the sort order.</p>
<p><strong>Step 1: Create a Parameter for the Sort Measure</strong></p>
<p>Pretty much the same step as in the basic approach, but only one entry per measure in the list of values:</p>
<p><a href="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833015392ff80c9970b-pi"><img style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="Parameter Sort Measure enhanced - click to enlarge" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833015392ff80d5970b-pi" border="0" alt="Parameter Sort Measure enhanced - click to enlarge" width="260" height="234" /></a><strong>Step 2: Create a second Parameter for the Sort Order</strong></p>
<p>This is a new step. Create another Parameter, again with data type <em>String</em>, but only with two entries in the list of values: ascending and descending. We call this Parameter [Sort Order]:</p>
<p><a href="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330162fc54d9b8970d-pi"><img style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="Parameter Sort Order enhanced - click to enlarge" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833015392ff80ea970b-pi" border="0" alt="Parameter Sort Order enhanced - click to enlarge" width="260" height="234" /></a><strong>Step 3: Create a Calculated Field to transform Text Fields to Numbers</strong></p>
<p>Another additional step is necessary. Since we want to sort the view ascending or descending not only by [Profit] and [Sales], but also by [Customer State Name], we have to transform the names of the state into a number.</p>
<p>Here is one possible way of doing this: A new Calculated Field ([State String Number]) converts the first 4 characters of the state names to a number using the function <em>ASCII</em>. Multiplying the characters by decimal powers and adding them results in a four-digit number which we can use for sorting the state names.</p>
<p><a href="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330162fc54d9c4970d-pi"><img style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="Calculated Field 1 enhanced - click to enlarge" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833015392ff8106970b-pi" border="0" alt="Calculated Field 1 enhanced - click to enlarge" width="320" height="245" /></a>Agreed, this is a brute-force method. However, it works, at least in most cases. Please be advised that this technique will not work 100% correctly, if there are state names starting with the same 4 characters (e.g. North Carolina and North Dakota). But it is close enough for this example.</p>
<p><strong>Step 4: Create a Calculated Field for the Sort Measure</strong></p>
<p>This step is pretty much the same as step 3 of the basic approach, but the calculation is different. It is a <em>CASE</em> statement based on the Parameter [Sort States by] again, but please notice the additional <em>IF</em>-clauses within each <em>WHEN</em> statement. Furthermore we have to use aggregations (<em>SUM</em> and <em>AVG</em>) in order to make the formula work for sorting the state names:</p>
<p><a href="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330162fc54d9cf970d-pi"><img style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="Calculated Field 2 enhanced - click to enlarge" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833015436d30fcc970c-pi" border="0" alt="Calculated Field 2 enhanced - click to enlarge" width="320" height="236" /></a>The <em>CASE</em> statement is pretty complex, including <em>IF THEN </em>statements within each <em>WHEN</em>. If you find this too hard to read and understand, there is another way to simplfy this Calculated Field.</p>
<p>Create another Calculated Field and call it - let’s say – [Sort Sign]:</p>
<p><em>IF [Sort Order] = "Ascending" THEN </em></p>
<p><em>1 </em></p>
<p><em>ELSE </em></p>
<p><em>-1 </em></p>
<p><em>END </em></p>
<p>You can now simplify your formula of [State Sort Measure]:</p>
<p><a href="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330162fc54d9f8970d-pi"><img style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="Calculated Field 2 enhanced (alternative) - click to enlarge" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833015436d30fe3970c-pi" border="0" alt="Calculated Field 2 enhanced (alternative) - click to enlarge" width="320" height="172" /></a>The result is exactly the same. However, you transferred the repeated <em>IF THEN</em> statements to another Calculated Field and simplified the <em>CASE</em> statement. This is probably easier to read and understand.</p>
<p><strong>Step 5: Set the Sort Order of the Dimension on the Row Shelf</strong></p>
<p>This one is exactly the same as step 3 of the basic approach.</p>
<p><strong>Step 6: Show Parameter Controls</strong></p>
<p>Again the same procedure as in step 4 of the basic approach, but this time you show both Parameter Controls: [Sort States by] as a compact list again and [Sort Order] as a single value list (radio buttons).</p>
<p>That’s it. Two simple steps more than the basic approach and you are good to go.</p>
<p>Here is the interactive enhanced version on Tableau Public:</p>

<script type="text/javascript" src="http://public.tableausoftware.com/javascripts/api/viz_v1.js"></script><div class="tableauPlaceholder" style="width:504px; height:769px;"><noscript><a href="#"><img alt="Dynamic Sort Dashboard - enhanced " src="http:&#47;&#47;public.tableausoftware.com&#47;static&#47;images&#47;dy&#47;dynamic_sort_enhanced&#47;DynamicSortDashboard&#47;1_rss.png" style="height: 100%; width: 100%; border: none" /></a></noscript><object class="tableauViz" width="504" height="769" style="display:none;"><param name="host_url" value="http%3A%2F%2Fpublic.tableausoftware.com%2F" /><param name="name" value="dynamic_sort_enhanced&#47;DynamicSortDashboard" /><param name="tabs" value="no" /><param name="toolbar" value="yes" /><param name="static_image" value="http:&#47;&#47;public.tableausoftware.com&#47;static&#47;images&#47;dy&#47;dynamic_sort_enhanced&#47;DynamicSortDashboard&#47;1.png" /><param name="animate_transition" value="yes" /><param name="display_static_image" value="yes" /><param name="display_spinner" value="yes" /><param name="display_overlay" value="yes" /></object></div><div style="width:504px;height:22px;padding:0px 10px 0px 0px;color:black;font:normal 8pt verdana,helvetica,arial,sans-serif;"><div style="float:right; padding-right:8px;"><a href="http://www.tableausoftware.com/public?ref=http://public.tableausoftware.com/views/dynamic_sort_enhanced/DynamicSortDashboard" target="_blank">Powered by Tableau</a></div></div>


<h4><strong><span>The Drawbacks</span></strong></h4>
<p>The technique described above is a workaround. No more, no less.</p>
<p>Like any other workaround, it comes with some limitations and pitfalls. It takes some additional time to implement it (not too much in this case, though) and you have to define the sorting measures in advance. Those are only minor drawbacks from my point of view.</p>
<p>However, you should be aware of a more serious shortcoming of this technique. It only works as long as you or the user of your dashboard doesn’t change the sort order by using Tableau’s built-in sorting. After you selected a field and sorted it with the sort buttons on the toolbar, our dynamic sorting technique does not work anymore.</p>
<p>The root cause for this is the fact that Tableau sets the sort order to manual, if you are using the toolbar sort buttons. In this case, you have to go to the worksheet again and set the sort order of the dimension on the Row Shelf to <em>Sort by Field</em> again.</p>
<p>It goes without saying that the technique described above also stops working if you change the persistent sort on the worksheet to sort by data source order, alphabetic sort, another field or to manual sort.</p>
<p>As long as you are aware of this undesired behavior, you might be ok. However, this could be confusing for a user who does not know about this shortcoming. Even worse, if he has only access to the dashboard, but not to the worksheet (e.g. if he is using Tableau Reader or a dashboard on Server or Public), he can’t do anything about it.</p>
<p>There is one more drawback you should be aware of: using the Calculated Field as the sort criterion results in a more complex query and this may have negative impact on the database performance. If you encounter this problem in your implementation, you could grab the generated query from your Tableau Desktop log file and tune this with your DBA.</p>
<h4><strong><span>What’s next?</span></strong></h4>
<p>This was the first post of a series of articles on how to expand your reach in Tableau with parameters and to spice up your Tableau dashboards with even more dynamic, interactive features than Tableau already provides as a standard.</p>
<p>The next article will show a similar technique to create an interactive hierarchy.</p>
<p>Stay tuned.</p><img src="http://feeds.feedburner.com/~r/ClearlyAndSimply/~4/XIJ2SJFjfWY" height="1" width="1"/>]]></content:encoded>


<category>Tableau</category>

<dc:creator>Robert</dc:creator>
<pubDate>Sat, 12 Nov 2011 19:00:00 +0100</pubDate>

<feedburner:origLink>http://www.clearlyandsimply.com/clearly_and_simply/2011/11/dynamic-sorting-with-tableau.html</feedburner:origLink></item>
<item>
<title>Color Coded Bar Charts with Microsoft Excel</title>
<link>http://feedproxy.google.com/~r/ClearlyAndSimply/~3/HhX_o4qsN_k/color-coded-bar-charts-with-microsoft-excel.html</link>
<guid isPermaLink="false">http://www.clearlyandsimply.com/clearly_and_simply/2011/08/color-coded-bar-charts-with-microsoft-excel.html</guid>
<description>Different techniques of how to color encode data points of a bar chart based on a second data series in Microsoft Excel</description>
<content:encoded><![CDATA[<h3><span><strong>Different techniques of how to color encode data points of a bar chart based on a second data series in Microsoft Exce</strong>l</span></h3>
<p><img align="left" alt="Colored Bar Chart Intro" border="0" height="260" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833014e8aac1167970d-pi" style="background-image: none; margin: 0px 15px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; padding-top: 0px; border-width: 0px;" title="Colored Bar Chart Intro" width="235" />Color encoding can be a very powerful technique for data visualization. <a href="http://www.clearlyandsimply.com/clearly_and_simply/2009/02/there-is-more-than-one-way-to-heat-a-map.html" title="There is more than one way to heat a map">Heat Maps</a> or <a href="http://www.clearlyandsimply.com/clearly_and_simply/choropleth-maps/" title="Choropleth Maps">Choropleth Maps</a> are classical examples of visualizing data by color encoding.</p>
<p>However, you can add color encoding to almost any kind of visualization. For instance, using colors on bar charts can display additional information of the data and – if used carefully – considerably improve the significance of the visualization without requiring further real estate on a dashboard.</p>
<p>With <a href="http://www.tableausoftware.com/" title="Tableau Software">Tableau Software</a>, color encoding your charts is a piece of cake. Simply drag the dimension or measure to the color shelf and you are done. Microsoft Excel has no comparable built-in functionality. However, this doesn’t mean you can’t use color encoding in your Excel charts. Of course you can.</p>
<p>Today’s post describes different techniques of how to color encode Microsoft Excel bar charts, with or without using VBA. As usual, all described techniques are coming with an example workbook for free download.</p>


<h4><strong>The Basic Idea</strong></h4>
<p>The basic idea is simple and obvious: Add another dimension or measure to your bar chart by coloring the bars according to the values of another data series.</p>
<p>One practical example would be a bar chart displaying one performance KPI of sales agents (e.g. sales figures, revenues, or the like) using the lengths of the bars and visualizing their sales regions (e.g. north, east, south, west) by coloring the bars with four different colors. More information in the same amount of real estate on your dashboard.</p>
<p>Microsoft Excel does not provide a built-in feature to do this color encoding, but – of course – this does not mean you can’t do it at all. As always, there is more than one way to skin the cat. Here are three different ways of how to accomplish this with Microsoft Excel.</p>
<h4><strong>Technique 1 – Several Data Series</strong></h4>
<p>I am sure you know this technique already. If you want to color encode categories (like in the example mentioned above), you add as many data series to your bar chart as you need (e.g. four sales regions in our example above) and format them using different fill colors.</p>
<p>A very simple <em>IF</em>-formula makes sure each data series contains the KPI values only if the row (i.e. the sales agent) belongs to the according category (i.e. the sales region) and <em>NV()</em> otherwise.</p>
<p>The result could look like this:</p>
<p><img alt="Technique 1 – Several Data Series (Dimension)" border="0" height="291" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330154348c39b8970c-pi" style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; padding-top: 0px; border-width: 0px;" title="Technique 1 – Several Data Series (Dimension)" width="520" /></p>
<p>Here is an example workbook for free download:</p>
<p style="text-align: center;"><a href="http://www.clearlyandsimply.com/files/2011/08/colored_bar_chart_data_series_categories.xls" title="Download Colored Bar Chart Data Series (Categories) - (Excel 2003 workbook, 79K)">Download Colored Bar Chart Data Series (Categories) - (Excel 2003 workbook, 79K)</a></p>
<p>You can use exactly the same technique if you want to color code a measure instead of a dimension. All you have to do is to cluster the values in categories, e.g. by defining value ranges or using percentiles.</p>
<p>You would probably use different hues of the same color instead of different colors, like this:</p>
<p><img alt="Technique 1 – Several Data Series (Measure)" border="0" height="243" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833014e8aac1190970d-pi" style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; padding-top: 0px; border-width: 0px;" title="Technique 1 – Several Data Series (Measure)" width="520" /></p>
<p>Here is the according workbook for free download:</p>
<p style="text-align: center;"><a href="http://www.clearlyandsimply.com/files/2011/08/colored_bar_chart_data_series_measures.xls" title="Download Colored Bar Chart Data Series (Measures) - (Excel 2003 workbook, 86.5K)">Download Colored Bar Chart Data Series (Measures) - (Excel 2003 workbook, 86.5K)</a></p>
<h4><strong>Technique 2 – Change the Fill Color using VBA</strong></h4>
<p>You don’t mind using some simple VBA routines in your workbook? Good. A very small VBA sub can automatically change the fill color of the bars. Thus, you need only one data series in your bar chart. The set-up is very similar to technique 1 (color encoding a measure):</p>
<ul>
<li>Define value ranges (as many as you like) </li>
<li>Define the color scale using the fill color of cells </li>
<li>Use a simple MATCH formula to assign each value to the correct value range </li>
<li>The rest is done by a very simple VBA routine looping through all data points in a <em>For Next</em> statement and setting the fill color to the according fill color of the range this value belongs to. </li>
</ul>
<p>Have a look at the worksheet [calculation] and the small VBA routine of this workbook:</p>
<p style="text-align: center;"><a href="http://www.clearlyandsimply.com/files/2011/08/colored_bar_chart_fill_color_vba.xls" title="Download Colored Bar Chart Fill Color (VBA) - (Excel 2003 workbook, 89K)">Download Colored Bar Chart Fill Color (VBA) - (Excel 2003 workbook, 89K)</a></p>
<p>The VBA sub “ColorBarChart” is assigned to the spinner on the dashboard, i.e. the coloring changes each time you are switching to another data set. Of course, you could also call this sub from a Worksheet_Calculate or any other event driven procedure.</p>
<h4><strong>Technique 3 – Change the Transparencies using VBA</strong></h4>
<p>This technique is limited to Excel 2007 or later. Like technique 2, it uses VBA. However, it does not change the fill color of the bars, but the transparencies. The set-up of the workbook is easier than with the other 2 techniques. Like technique 2, you need only one data series in your bar chart. You do not have to define range values, all you have to do is to create a helper column calculating the transparency values with a pretty simply formula.</p>
<p>Here is an example how this would look like:</p>
<p><img alt="Technique 3 – Transparencies" border="0" height="276" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330154348c39d6970c-pi" style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; padding-top: 0px; border-width: 0px;" title="Technique 3 – Transparencies" width="520" /></p>
<p>The VBA procedure is very similar to the one used for technique 2. Instead of changing the property .Interior.ColorIndex, it changes .Fill.Format.Transparency, using the percentage values in the helper column (see above).</p>
<p>That’s it. One helper column and 8 lines of VBA code and you are good to go.</p>
<p>Here is the workbook for free download:</p>
<p style="text-align: center;"><a href="http://www.clearlyandsimply.com/files/2011/08/colored_bar_chart_transparencies_vba.xlsm" title="Download Colored Bar Chart Transparencies (VBA) - (Excel 2007 workbook, 28.8K)">Download Colored Bar Chart Transparencies (VBA) - (Excel 2007 workbook, 28.8K)</a></p>
<h4><strong>Please use this with caution</strong></h4>
<p>Color coding is a very interesting way of visualizing data, no doubt about it. However, you should always think twice before using it. From my point of view, color coding sales regions of agents (as shown in the example for technique 1) adds a lot of very useful information. Imagine the bar chart would include more than 10 agents. You could easily see from the colors of the bar that e.g. 5 out of 10 of the top performers are coming from one sales region.</p>
<p>However, human eyes respectively the human brain are not very good in comparing values by color hues. For instance I would not recommend using a bar chart displaying the revenues of your company branches as the bars and their profits as the color. I would use 2 aligned bar charts instead. This makes both KPIs comparable at a glance.</p>
<p>Still, I do believe there are some use cases where coloring bars can be a viable alternative. All you have to do is to thoroughly think about which visualization tells your story best.</p>
<h4><strong>A Practical Example – A Color Coded Tornado Chart</strong></h4>
<p><img align="left" alt="Colored Tornado Chart" border="0" height="372" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833015390b8c700970b-pi" style="background-image: none; margin: 0px 15px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; padding-top: 0px; border-width: 0px;" title="Colored Tornado Chart" width="290" />The recent post described my “non-entry” to the <a href="http://www.tableausoftware.com/about/blog/2011/07/tableau-public-sports-viz-challenge">The Tableau Interactive Sports &quot;Viz&quot; Contest</a>: <a href="http://www.clearlyandsimply.com/clearly_and_simply/2011/07/premier-league-historical-statistics.html" title="The History of Premier League Statistics">The History of Premier League Statistics</a>.</p>
<p>This Tableau workbook included a variety of tables and visualizations and one of them used color coded bar charts: Dashboard 2 contained a chart showing the goals of each team at any point in time: Goals for, goals against and goal difference.</p>
<p>A tornado chart is not far to seek for this data set. One bar for each team, goals for on the right of the vertical axis and goals against on the left. This is pretty intuitive, I think.</p>
<p>But what about the goal difference? Sure, the bars leaning to the right are the ones with the better goal difference and vice versa. However, have a look at the example shown above. Imagine you would not have the color coding, would you be able to see at a glance that Aston Villa’s goal difference is worse than the one of Blackburn Rovers or that Liverpool’s goal difference is negative? I do not think so.</p>
<p>Thus, from my point of view this is a very good example of how to effectively use color coding on a bar or tornado chart. Sure, you can always add another bar chart displaying the goal differences, but if you are short of real estate on your dashboard, color coding can be a viable alternative in this case.</p>
<p>The implementation isn’t too difficult. It somehow is a combination of technique 1 and 3: four data series in the chart and a slightly changed VBA routine adjusting the transparencies of all 4 data series. Nothing new under the sun. Here is the example workbook for free download:</p>
<p style="text-align: center;"><a href="http://www.clearlyandsimply.com/files/2011/08/colored_tornado_chart.xlsm" title="Download Colored Tornado Chart - (Excel 2007 workbook, 60.1K)">Download Colored Tornado Chart - (Excel 2007 workbook, 60.1K)</a></p>
<h4><strong>Acknowledgements</strong></h4>
<p>Many thanks go again to my friend <a href="http://chandoo.org/wp/2011/08/10/mlb-pitching-stats-dashboard/" title="Dan L">Dan L</a>, who was once more kind enough to invest some of his precious time reviewing my ideas and workbooks. A big time thank you very much, Dan. Your feedback is invaluable.</p>
<h4><strong>What’s next?</strong></h4>
<p>I am planning to have two Tableau articles during the next weeks: a new <a href="http://www.clearlyandsimply.com/clearly_and_simply/tableau-quick-tips/" title="Tableau Quick Tips">Tableau Quick Tip</a> and an article on the making of the <a href="http://www.clearlyandsimply.com/clearly_and_simply/2011/07/premier-league-historical-statistics.html" title="Premier League Historical Statistics">Premier League Historical Statistics</a>.</p>
<p>If you are more interested in articles on Microsoft Excel, please hang in there. I am also working on a follow-up post to the <a href="http://www.clearlyandsimply.com/clearly_and_simply/2011/06/emulate-excel-pivot-tables-with-texts-in-the-value-area-using-vba.html" title="Pivot Table with texts in the value area">Pivot Table with texts in the value area</a> and on an article about how to drill-down within an Excel dashboard.</p>
<p>Stay tuned.</p><img src="http://feeds.feedburner.com/~r/ClearlyAndSimply/~4/HhX_o4qsN_k" height="1" width="1"/>]]></content:encoded>


<category>Microsoft Excel</category>
<category>Visualization</category>

<dc:creator>Robert</dc:creator>
<pubDate>Mon, 15 Aug 2011 22:00:00 +0200</pubDate>

<feedburner:origLink>http://www.clearlyandsimply.com/clearly_and_simply/2011/08/color-coded-bar-charts-with-microsoft-excel.html</feedburner:origLink></item>
<item>
<title>Premier League Historical Statistics</title>
<link>http://feedproxy.google.com/~r/ClearlyAndSimply/~3/8knRhrVt6XM/premier-league-historical-statistics.html</link>
<guid isPermaLink="false">http://www.clearlyandsimply.com/clearly_and_simply/2011/07/premier-league-historical-statistics.html</guid>
<description>Interactive Visualization of 15 years of England’s Football Premier League – a non-competitive Contribution to Tableau’s “Interactive Sports Viz Contest”</description>
<content:encoded><![CDATA[<h3><strong>Interactive Visualization of 15 years of England’s Football Premier League – a non-competitive Contribution to Tableau’s “Interactive Sports Viz Contest”</strong></h3>
<p><img style="background-image: none; margin: 0px 15px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; padding-top: 0px; border-width: 0px;" title="Premier League Logo" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb998833014e89f0e3a9970d-pi" border="0" alt="Premier League Logo" width="111" height="159" align="left" />Last week, Tableau announced a new visualization contest: <a title="The Tableau Interactive Sports &quot;Viz&quot; Contest" href="http://www.tableausoftware.com/about/blog/2011/07/tableau-public-sports-viz-challenge">The Tableau Interactive Sports "Viz" Contest</a>.</p>
<p>Intrigued with the very attractive prices Tableau announced, I would have loved to contribute a workbook. Unfortunately, I am not allowed to, because the contest is open to US residents only.</p>
<p>If you are a regular reader of this blog, you may have noticed that I love using sports data for my examples. We had several visualizations (Tableau and/or Excel) of Football statistics and even one article using Baseball data:</p>
<ul>
<li><a title="FIFA World Cup Statistics with Tableau" href="http://www.clearlyandsimply.com/clearly_and_simply/2010/06/fifa-world-cup-statistics-with-tableau.html">FIFA World Cup Statistics with Tableau</a></li>
<li><a title="FIFA World Cup Scorers Statistics with Tableau" href="http://www.clearlyandsimply.com/clearly_and_simply/2010/06/fifa-world-cup-scorers-statistics-with-tableau.html">FIFA World Cup Scorers Statistics with Tableau</a></li>
<li><a title="The History of FIFA World Cup Host Elections" href="http://www.clearlyandsimply.com/clearly_and_simply/2010/12/the-history-of-fifa-world-cup-host-elections.html">The History of FIFA World Cup Host Elections</a></li>
<li><a title="Combine Tables and Charts on Excel Dashboards" href="http://www.clearlyandsimply.com/clearly_and_simply/2010/05/combine-tables-and-charts-on-excel-dashboards.html">Football League Tables (Combine Tables and Charts on Excel Dashboards)</a></li>
<li><a title="An Underrated Chart Type: The Band Chart" href="http://www.clearlyandsimply.com/clearly_and_simply/2011/04/an-underrated-chart-type-the-band-chart.html">MLB Salaries (An Underrated Chart Type: The Band Chart)</a></li>
</ul>
<p>Since I am so into visualizing sports data, I decided to publish the workbook I would have contributed to the contest: a Tableau visualization of 15 years of historical data of the English Premier League.</p>
<p>Today’s article provides the workbook for direct interaction here or for download from Tableau Public. A follow-up post later this week will describe step-by-step tutorials of some of the most interesting techniques I used for the implementation.</p>
<p>

</p>
<h4><strong>The Idea</strong></h4>
<p><a title="Combine Tables and Charts on Excel Dashboards" href="http://www.clearlyandsimply.com/clearly_and_simply/2010/05/combine-tables-and-charts-on-excel-dashboards.html">Combine Tables and Charts on Excel Dashboards</a> provided 2 Excel workbooks visualizing the fixtures and the tables of the English Premier League and the German Bundesliga, solely based on the match results. This was the ignition spark. The idea of today’s article was providing similar dashboards using Tableau instead of Excel.</p>
<p>I have to admit that I could not fully oblige this requirement. For one single view (the development of the team’s rankings over time) I needed an additional data source. I will go into further details of this issue in the follow-up post.</p>
<p>Still: all other views of the workbook are based on a data source containing nothing else than match results. This proves the flexibility of Tableau when it comes to the requirement of additional calculations based on the underlying data. For more information on the power of Calculated Fields, please refer to this article: <a title="Calculated Fields in Tableau" href="http://www.clearlyandsimply.com/clearly_and_simply/2010/10/calculated-fields-in-tableau.html">Calculated Fields in Tableau</a>.</p>
<h4><strong>The Premier League Visualization using Tableau</strong></h4>
<p>Here is the Tableau workbook on Tableau Public:</p>

<script type="text/javascript" src="http://public.tableausoftware.com/javascripts/api/viz_v1.js"></script><div id="tableau_hide_this"style="width:504px; height:1025px;"></div><object class="tableauViz" width="504" height="1025" style="display:none;"><param name="host_url" value="http%3A%2F%2Fpublic.tableausoftware.com%2F" /><param name="name" value="premier_league&#47;D1-ResultsandTable" /><param name="tabs" value="yes" /><param name="toolbar" value="yes" /><param name="animate_transition" value="yes" /><param name="display_static_image" value="yes" /><param name="display_spinner" value="yes" /><param name="display_overlay" value="yes" /></object><noscript>English Premier League - Results and Table <br /><a href="#"><img alt="English Premier League - Results and Table " src="http:&#47;&#47;public.tableausoftware.com&#47;static&#47;images&#47;pr&#47;premier_league&#47;D1-ResultsandTable&#47;1_rss.png" height="100%" /></a></noscript><div style="width:504px;height:22px;padding:0px 10px 0px 0px;color:black;font:normal 8pt verdana,helvetica,arial,sans-serif;"><div style="float:right; padding-right:8px;"><a href="http://www.tableausoftware.com/public?ref=http://public.tableausoftware.com/views/premier_league/D1-ResultsandTable" target="_blank">Powered by Tableau</a></div></div>



<h4><strong>The Dashboards</strong></h4>
<p>The workbook consists of 3 different dashboards. Use the tabs at the top to switch between the different visualizations:</p>
<ol>
<li>The first dashboard shows the fixtures of the selected match day, the table at the end of this match day and some additional statistics of the actual date and the to date aggregations. </li>
<li>The second dashboard visualizes the most important statistics like the points, the wins, draws and losses and the goals and goal differences per team. Additionally it show the wins, draws, losses from match day one to date on a heat map. </li>
<li>The third dashboard allows you to watch the “race”. It shows all teams and their points on the first view and the changes of the ranking in the table over time with arrow shapes in the second view. This dashboard is especially interesting if you are “walking through” a season using the match day slider. </li>
</ol>
<p>You will notice a fourth dashboard, but this is just the edition notice.</p>
<h4><strong>The Interactive Features</strong></h4>
<p>The contest is called <a title="The Tableau Interactive Sports " href="http://www.tableausoftware.com/about/blog/2011/07/tableau-public-sports-viz-challenge">the Tableau Interactive Sports "Viz" Contest</a>. Thus, I assumed the focus should be on interactivity. Here are the main interactive features of this workbook:</p>
<ul>
<li>Select one season from a drop down list (15 seasons, from 1996/97 through 2010/11). All displayed results will be filtered by the selection and show the results of this season. </li>
<li>Select a match day (1 to 38). The dashboards show the fixtures of this day, a tables and different views visualizing the results after this match day. The slide control and the play buttons allow you to switch to a certain match day or to “walk through” a complete season and watch the changes of the visualizations. </li>
<li>Sort the teams using the drop down list “Sort by” descending by points, wins, draws, losses, goals for, goals against and goal difference. </li>
<li>The filter drop down “Table type” allows you to switch from the regular table including all matches to the home table or the away table, only considering the matches played home or away. </li>
<li>Actions defined on the dashboards 2 and 3 will highlight one team across all views of the dashboard after clicking on a row, e.g. if you click on one team in the bar chart on dashboard 2, this team will also be highlighted on the Win-Draw-Loss chart at the bottom of the dashboard. </li>
<li>Tooltips provide a variety of additional information when hovering over a view. E.g. if you hover over the Win-Draw-Loss chart on the second dashboard, the tooltips will provide you with detailed information on this particular match, like the opponents and the result. Hovering over the table on dashboard 1 shows a legend explaining the column header abbreviations.&nbsp; </li>
</ul>
<h4><strong>The Visualizations</strong></h4>
<p>The visualization are hopefully self explanatory. Here is just a brief description:</p>
<p>Dashboard 1</p>
<p>The usual suspects. This is what you probably are used to see at the end of any sportscast on Saturday or Sunday night: the fixtures, the results, the actual league table and some additional statistics like the total goals, the goals per match, etc.</p>
<p>Very simple tables, yet the most basic and most important information and overview.</p>
<p>Dashboard 2</p>
<p>Additional visualizations of the most important facts on dashboard 1. The points (visualized with a sorted bar chart), the wins, draws and losses so far (a stacked bar chart) and the goals for, goals against and goals difference (a tornado chart, colored from green to red based on the goal difference). Additionally, the heat map at the bottom of the dashboard visualizes the wins, draws and losses for each team over time.</p>
<p>Dashboard 3</p>
<p>This is not the snapshot-type of dashboard. This visualization reveals its real power when using it as a slide show. With the slider or the play buttons for the match day, you can easily watch how teams catch up or fall behind in the course of time. Furthermore, you can see the development of the ranking of all teams over time on the view at the bottom of the dashboard. A green arrow up indicates an improvement of the rank compared to the previous match day, a red arrow down means the team went down in the ranking and a black arrow to the right shows that the team has the same rank as last week. This way you can easily identify how the ranking of a team developed over time.</p>
<h4><strong>The Analytics – What can you see from this Visualization</strong></h4>
<p>I definitely cannot provide a description of all the insights Tableau provides here. Thus, here are only three interesting examples of what you can see from the visualizations above (just looking at Manchester United in the last season 2010/2011):</p>
<ul>
<li>ManU has never been number one before match day 15. However, from that on, they never left the top of the list again until the end of the season. </li>
<li>This is somehow surprising, because ManU lost the first match on match day 18 (away at Chelsea). They never lost a match before, but within the first 14 matches, they had 7 draws and only 7 wins. </li>
<li>ManU won the title, but on the away table, they are only ranked on position 5. Thus, they obviously won the title at home (18 wins, 1 draw, 0 losses). </li>
</ul>
<p>There is much more to discover within this data. Please have a look for yourself.</p>
<h4><strong>Disclaimer</strong></h4>
<p>As mentioned above, the workbook is based on the match results and aggregates / calculates the tables and other visualizations from this data. Thus, the dashboards do not reflect any possible point penalties, e.g. <a title="Portsmouth's nine point deduction" href="http://www.guardian.co.uk/football/2010/mar/16/portsmouth-nine-points-deduction">Portsmouth's nine point deduction</a> in 2009/2010 is not included. The tables are reflecting the sports, nothing else. They do not necessarily represent the official tables.</p>
<h4><strong>A Personal Note</strong></h4>
<p>I do not understand why the Tableau contest is limited to US residents. I suspect it may be due to legal issues with price rewarding in the United States (well, this was the explanation Tableau provided with their <a title="Dozens of Vizzes Shine in the Tableau Interactive Viz Contest" href="http://www.tableausoftware.com/about/blog/2011/06/dozens-vizzes-shine-tableau-interactive-viz-contest-11481">last contest</a>, at least).</p>
<p>I admit, I do not know anything about US legal requirements for such contests and the price rewarding. However, in my humble opinion, a company with a subsidiary in London should be able to find ways of opening their contests to all of their customers around the world. Especially in view of the fact that Tableau recently hyped their ongoing <a title="Tableau 6.1 – Localized and Globalized" href="http://www.tableausoftware.com/about/blog/2011/07/tableau-localized-globalized">international expansion</a>.</p>
<p>Come on, Tableau folks, you are better than this.</p>
<h4><strong>What’s next?</strong></h4>
<p>The Premier League workbook contains a variety of little Tableau tricks and knacks. The next article will describe a selection of the most interesting techniques in detailed step-by-step walkthroughs.</p>
<p>Stay tuned.</p><img src="http://feeds.feedburner.com/~r/ClearlyAndSimply/~4/8knRhrVt6XM" height="1" width="1"/>]]></content:encoded>


<category>Dashboards</category>
<category>Tableau</category>
<category>Visualization</category>

<dc:creator>Robert</dc:creator>
<pubDate>Mon, 18 Jul 2011 21:00:00 +0200</pubDate>

<feedburner:origLink>http://www.clearlyandsimply.com/clearly_and_simply/2011/07/premier-league-historical-statistics.html</feedburner:origLink></item>
<item>
<title>Emulate Excel Pivot Tables with Texts in the Value Area using VBA</title>
<link>http://feedproxy.google.com/~r/ClearlyAndSimply/~3/fS81GUsIqNU/emulate-excel-pivot-tables-with-texts-in-the-value-area-using-vba.html</link>
<guid isPermaLink="false">http://www.clearlyandsimply.com/clearly_and_simply/2011/06/emulate-excel-pivot-tables-with-texts-in-the-value-area-using-vba.html</guid>
<description>How to create a Microsoft Excel Pivot Table lookalike Crosstab with Texts in the Value Area using VBA</description>
<content:encoded><![CDATA[<h3><strong><span>How to create a Microsoft Excel Pivot Table lookalike Crosstab with Texts in the Value Area using VBA</span></strong></h3>
<p><a href="http://www.clearlyandsimply.com/.a/6a00e554d9fb99883301538f8ca6f3970b-pi"><img align="left" alt="Pivot Tables with Texts (VBA version) - click to enlarge" border="0" height="135" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb99883301538f8ca700970b-pi" style="background-image: none; margin: 0px 15px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; padding-top: 0px; border-width: 0px;" title="Pivot Tables with Texts (VBA version) - click to enlarge" width="260" /></a>The <a href="http://www.clearlyandsimply.com/clearly_and_simply/2011/06/emulate-excel-pivot-tables-with-texts-in-the-value-area-using-formulas.html" title="Emulate Excel Pivot Tables with Texts in the Value Area using Formulas">recent post</a> showed a way how to create a Pivot Table lookalike crosstab with texts in the value area.</p>
<p>However, due to the fact that it was restricted to Excel formulas, the approach came with a couple of drawbacks. Using formulas forces you to define the layout and the size of the crosstab in advance in a static structure. It goes without saying that this considerably limits the usability in real life.</p>
<p>Without VBA, there is no way out. However, some VBA helps to overcome almost all of the disadvantages of the formula based approach. Today’s post is the announced follow-up: it describes how to use VBA to emulate a Pivot Table lookalike crosstab with texts in the value area, as always including the Excel workbook for free download.</p>


<h4><strong>The Idea and Concept</strong></h4>
<p>The basic idea is a fixed and named cell range on a separate worksheet steering the layout of the crosstab, i.e. the definition which data field goes to which part of the crosstab (value area, rows, columns and filter).</p>
<p>Everything else is done by a VBA routine analyzing the raw data and creating and formatting the crosstab. This routine is executed whenever something changes (data, layout definition or filter).</p>
<p>The crosstab will</p>
<ul>
<li>show only the relevant category entries in the rows and columns </li>
<li>display filter, row and column category entries sorted ascending </li>
<li>display the texts in the value area as values (no formulas) </li>
<li>include an automatically created dropdown (form control) as the filter input control </li>
<li>automatically be formatted </li>
</ul>
<h4><strong>The Preparation of the Workbook</strong></h4>
<p>Although we will have the VBA routine to do the laborious work, we still need a little bit of preparation of the Excel workbook:</p>
<ul>
<li>Bring your data into your workbook. We are using the same fictitious example data of a project risk list again </li>
<li>Define a name for the cell range containing the data (“myData”) </li>
<li>Insert an additional worksheet [Control]. Here is an example screenshot: </li>
</ul>
<p><img alt="Worksheet Control" border="0" height="260" src="http://www.clearlyandsimply.com/.a/6a00e554d9fb9988330154335fe120970c-pi" style="background-image: none; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="Worksheet Control" width="249" /></p>
<blockquote>
<p>Columns C4:C7 define the layout of the pseudo Pivot Table. The numbers represent the column numbers within our data table. In the example shown above, the data from column 2 of the data table (the risk description) will be displayed in the value area of the crosstab, the data from column 4 (the impact) will go to the rows of the crosstab, column 5 (the probabilities) will be displayed in the columns of the crosstab and column 3 of the data table (the risk type) will be used as the filter. If you want to change the layout of the crosstab later, we do not have to change the VBA code. Instead, we simply change these 4 values. A combination of 2, 3, 4, 5 will bring the risk types to the rows, the impact to the columns and use the probability as the filter.</p>
</blockquote>
<blockquote>
<p>In cell C8 we define the width of the columns of our crosstab and in C9 we select the fill color for the row and column headers of the crosstab.</p>
<p>Cell C11 stores the actual selected filter.</p>
</blockquote>
<ul>
<li>Define names for the range B4:C9 (“myPivotTableDefinition”) and for C11 (“myFilterSelection”) in order to be able to address these cell ranges in VBA. </li>
<li>Finally insert a new worksheet [Pivot Table Risks] and assign a name to the top left cell of our pseudo Pivot Table (“myPivotTableStart”).<strong> <br /></strong></li>
</ul>
<h4><strong>The Implementation – The VBA</strong></h4>
<p>I think I don’t have a snowball’s hope in hell to describe and explain the VBA code line by line. I did my very best to write readable and comprehensible code (not sure if I succeeded) and added a few comments. Thus, I will restrict myself to a few hints on the general structure of the VBA:</p>
<p>There is only one single module in the workbook containing 2 main functions and 2 main subs:</p>
<ol>
<li>The function <em>UniqueItems</em> returns a list of unique items from an array of values </li>
<li>The function <em>FindPosition </em>does pretty much the same as the worksheet function <em>MATCH</em>. We could use Application.WorksheetFunction.Match(..) instead, but the VBA is faster than calling the worksheet function </li>
<li>The sub <em>QuickSort</em> sorts an array ascending </li>
<li>The sub <em>CreateTextPivotTable</em> - this is the main procedure </li>
</ol>
<p>The sub <em>CreatePivotTable</em> consists of the following main steps:</p>
<ul>
<li>Initialize the data structure and transfer the data and the Pivot Table definition from the worksheets to VBA variables </li>
<li>Delete the existing Pivot Table, unmerge cells, clear all formatting and delete the existing filter drop down </li>
<li>Prepare the filter: create a list of unique entries in the data field selected as the filter, add the entry “All” and create a filter dropdown on the worksheet </li>
<li>Detect the row and column headers by creating lists with unique items from the data fields selected for rows and columns </li>
<li>Loop through all data rows, detect their position within the crosstab (which row / which column) and calculate the number of entries in each field of the crosstab matrix </li>
<li>Calculate the maximum number of entries per row category </li>
<li>Write the crosstab to the worksheet </li>
<li>Format the crosstab </li>
<li>Update the named formula &quot;myPivotTable&quot; </li>
<li>Clean-Up (deallocate the data structure) </li>
</ul>
<p>The code will always delete the existing crosstab and create a new one from scratch. It has to be updated if</p>
<ul>
<li>… the data is changed or new data rows have been added </li>
<li>… the definition of the layout on worksheet [Control] has been changed </li>
<li>… the user changed the filter by using the dropdown </li>
</ul>
<p>The update of the crosstab after changing the filter is managed within the VBA code (using <em>.OnSection</em> of the dropdown). In order to make sure that the crosstab is always up to date after changes of the data or the [Control] worksheet, we call the sub <em>CreateTextPivotTable</em> within the event driven procedure Worksheet_Activate of the sheet [Pivot Table Risks]. Every time the sheet is activated, the crosstab will be updated.</p>
<p>That’s it.<strong></strong></p>
<h4><strong>The Pros</strong></h4>
<ul>
<li>It works (well, you expected that, didn’t you?) </li>
<li>It is easy to implement and easy to use </li>
<li>The layout of the crosstab can easily be changed </li>
<li>It eliminates most of the disadvantages of the static formula approach (see the cons described in the <a href="http://www.clearlyandsimply.com/clearly_and_simply/2011/06/emulate-excel-pivot-tables-with-texts-in-the-value-area-using-formulas.html" title="Emulate Excel Pivot Tables with Texts in the Value Area using Formulas">recent post</a>) </li>
</ul>
<h4><strong>The Cons</strong></h4>
<ul>
<li>VBA necessary </li>
<li>Some preparation of the workbook required, but by far less efforts than with the formula based solution </li>
<li>Limited to exactly one filter. There is no option for a crosstab without a filter or more than one filter. This would be possible, of course, but I tried to keep it as simple as possible </li>
<li>Error handling is next to nothing. For instance, the code will not check if it will overwrite data or formulas. There is no warning. You have to make sure that there is enough empty space right and below of the defined start cell of the crosstab </li>
<li>The layout definition is flexible, but not very user-friendly. A user form with dropdown lists to change the layout and the formatting would be more convenient </li>
</ul>
<h4><strong>The Performance</strong></h4>
<p>If you are using a more complex VBA procedure, the performance of the code is always an interesting topic. I did some stress testing. With a relatively small amount of data (150 data rows in the example workbook), the crosstab updates instantaneously. Using a database of 5,000 rows, the procedure takes 0.6 seconds, with 10,000 rows this increases to 1.2 seconds, with 65,000 data rows it takes even 6.4 seconds. Agreed, 6.4 seconds is everything else than a good user experience.</p>
<p>However, I do not think that matters in this specific case: unlike a real Pivot Table, we are not aggregating data. We are simply rearranging it and showing an enumeration in a tabular crosstab. From my point of view this wouldn’t make sense with a large database of 10,000 rows or more. Thus, performance shouldn’t be a problem.</p>
<h4><strong>The Download Link</strong></h4>
<p>Here is the Excel workbook for free download:</p>
<p style="text-align: center;"><a href="http://www.clearlyandsimply.com/files/2011/06/pivot_tables_with_texts_VBA.xls" title="Download Pivot Tables_with_Texts - VBA Approach (Excel 2003 workbook, 138K)">Download Pivot Tables_with_Texts - VBA Approach (Excel 2003 workbook, 121K)</a></p>
<p>Please be advised that the workbook is Excel 2003 file format, but I tested the code only with Excel 2010. If you encounter any problems with the file using Excel 2003 or earlier, please leave me a comment.</p>
<h4><strong>Acknowledgement</strong></h4>
<p>Many thanks go to Ulrik Willemoes, who was once more kind enough to spend some of his precious time reviewing my workbook and discussing it with me. As usual, Ulrik provided a couple of very interesting suggestions how the workbook could be improved. Many thanks, Ulrik!</p>
<p>I decided to save one of Ulrik’s best ideas for a follow-up post. So, if you liked this article, please stay tuned. There will be one more post on this topic coming soon.</p><img src="http://feeds.feedburner.com/~r/ClearlyAndSimply/~4/fS81GUsIqNU" height="1" width="1"/>]]></content:encoded>


<category>Data Analysis</category>
<category>Microsoft Excel</category>

<dc:creator>Robert</dc:creator>
<pubDate>Thu, 30 Jun 2011 20:00:00 +0200</pubDate>

<feedburner:origLink>http://www.clearlyandsimply.com/clearly_and_simply/2011/06/emulate-excel-pivot-tables-with-texts-in-the-value-area-using-vba.html</feedburner:origLink></item>

</channel>
</rss><!-- ph=1 -->

