Categories

Showing posts with label Advanced Tutorials. Show all posts
Showing posts with label Advanced Tutorials. Show all posts

Friday, January 16, 2015

Advanced Analysis – Pareto Charts (Step by Step Tutorial)

This article is part of the Advanced Analysis series of data visualization tutorials.

In this tutorial, we will be learning how to build Pareto charts. This tutorial uses the video demonstration of Pareto charts found here: Pareto Charts

A Pareto chart, named after Vilfred Pareto, is a type of chart that contains both bars and a line graph, where individual values are represented in descending order by bars, and the cumulative total is represented by the line [Wikipedia].

We will be using a Pareto chart to test the Pareto principle, also known as the 80-20 rule, which states that typically 80% of events come from 20% of the causes. This is very common in sales transactions, where 80% of the profits come from the top 20% of the customers. We will be using a packaged Tableau workbook pasted below for our analysis.

Download the data
Download the packaged Tableau workbook "Pareto Charts.twbx" and open the fileThe file is available herePareto Charts.twbx

Connect to the data
There are two data sources in the packaged workbook. Select the first data source labeled Sample - Superstore Sales English.











Build the first view
Now that you have your data source set up, begin building the view.

Step 1
In the Measures pane, double-click Sales.

Step 2
In the Dimensions pane, double-click Customer Name.

Step 3
Hover over the Sales axis in the view and select the sorting icon that appears to sort the customers in descending order of sales.



Step 4
Make the view fit the width of the screen by changing the Fit drop-down in the Toolbar section to be Entire View instead of Normal.









The view looks like this.




















Step 5
Change the aggregation on the Sales to be a running total by right-clicking the SUM(Sales) pill from Rows and selecting Quick Table Calculation > Running Total




Step 6.1
Add a second quick table calculation by right-clicking the SUM(Sales) > Edit Table Calculation...

Step 6.2
Check the "Perform a secondary calculation on the result." box.
For the "Secondary Type" drop-down, select Percent of Total

Step 6.3
For the "Running along" drop-down, select Customer Name.
For the "Summarize the values from" drop-down, select Customer Name. Click OK.




















The view looks like this.



Step 7.1
Right-click in the data window and select Create Calculated Field...




Step 7.2
In the "Name" textbox, type % of Customers
In the "Formula" box, type index()/size()

Step 8
Drag the % of Customers field onto the Columns shelf in front of the Customer Name pill.




Step 9
Drag the Customer Name pill off from the Columns shelf and onto the Detail shelf in the Marks card.




Step 10
Change the % of Customers pill to be computed using Customer Name by right-clicking the pill in the Columns shelf and selecting Compute using > Customer Name.

Step 11
Change the % of Customers pill to be computed using Customer Name by right-clicking the pill in the Columns shelf and selecting Compute using > Customer Name.




Step 12
Right-click the % of Customers axis and select Format...
Next to the "Numbers" drop-down, select Percentage. Set the number of decimal places to 0.




Step 13
Change the view-type from Automatic to Line by selecting the drop-down list in the Marks card and clicking on Line.








Step 14.1
To draw a reference line at the 20% mark, click the % of Customers axis and select Add a Reference Line, Band, or Box...

Step 14.2
Change the Value aggregation from Average to Constant using the drop-down list.
Set the constant at a value of 0.2.
Click OK.

Step 14.3
Change the Value aggregation to be a Constant.



Step 15
Add a constant reference line at the 80% mark for the % of Total Running Sum of Sales axis.

The final view looks like this.

Advanced Analysis – Benford's Law (Step by Step Tutorial)

This article is part of the Advanced Analysis series of data visualization tutorials.

In this tutorial, we will be testing out Benford's law on sample sales data. This tutorial uses the video demonstration of Benford's Law found here: Benford's Law

Benford's Law, also known as the First-Digit Law, refers to the frequency distribution of digits in many real-life sources of data, including sales data. In this distribution, 1 occurs as the leading digit in data about 30% of the time, 2 at 17.6% of the time, 3 at 12.5% of the time, while larger digits occur in that position less frequently: 9 is the first digit less than 5% of the time [Wikipedia]. The pattern of distribution frequency for digits 1-9 follow a logarithmic pattern. Benford's Law can be used to detect accounting fraud, among various other forgeries.

We will be using a bar chart to visualize the distribution of leading digits in our sales data using a packaged Tableau workbook pasted below for our analysis.

Download the data
Download the packaged Tableau workbook "Benford's Law.twbx" and open the fileThe file is available hereBenford's Law.twbx

Build the first view
Now that you have your data source set up, begin building the view.

Step 1.1
Create a calculated field to extract the leftmost digit for the Sales field. 
Right-click Sales from the Dimensions pane, select Create Calculated Field...




Step 1.2
In the "Name" textbox, type Leftmost Sales Value
In the "Formula" textbox, type LEFT(STR([Sales]), 1)
Click OK.




Step 2
From the Dimensions pane, drag Leftmost Sales Value to the Columns shelf.


Step 3
From the Measures pane, drag Number of Records to the Rows shelf.

Step 4
Right-click the Number of Records pill in the Rows shelf and select Quick Table Calculation > Percent of Total




Step 5
Click the "Abc" toolbar icon to show mark labels in the view.









The final view looks like this.
















As we can see, the distribution of frequency of leading digits in our sales data follows a logarithmic pattern from 1-9, thus holding Benford's Law to be true for our sample data set. Despite the data set being fictitious, it was likely not modeled after Benford's Law, which makes it just as interesting that it follows this pattern.

Tuesday, November 25, 2014

Advanced Analysis – Box Plots (Step by Step Tutorial)

This article is part of the Advanced Analysis series of data visualization tutorials.

The tutorial will cover how to create a box and whisker plot in Tableau using real data on homes sold in Seattle, Redmond, and Bellevue between September 2014 and October 2014. 

Download the data
Download the .csv file "Home Sales - Bellevue, Redmond, Seattle.csv". The file is available herehttps://drive.google.com/file/d/0B8ebWt6os-ryNlc4UTJnSm9GSUk/view

Connect to the data
Set up the data connection to the .csv file in Tableau.

Step 1
Open Tableau Desktop and connect to the data source by clicking Connect to Data.










Step 2
Under the In a File category, select Text File. Locate the Home Sales .csv file and select Open.
















Step 3
On the data connection page, click Go to Worksheet.












Build the view
Now that you have your data source set up, begin building the view.

Step 1
From the Measures pane, drag Price to the Rows shelf.

Step 2
From the Dimensions pane, drag City to the Columns shelf.

The view looks like this.


Step 3
Drag PropertyID onto the Detail shelf in the Marks card. 



Step 4.1 (Optional)
On the view, right-click the Price axis, select Format...


















Step 4.2
In the Format pane on the Axis tab, select the Numbers drop-down list and choose Currency (Standard).















Step 5
On the Marks card, in the Marks type drop-down list, select Circle.

Step 6 (Optional)
On the Marks card, select Size and re-size the circles to show greater distinction between properties.













Step 7.1
On the view, right-click the Price axis, select Add Reference Line, Band, or Box...

Step 7.2
In the pop-up window, select Box Plot

Step 7.3 (Optional)
In the Whiskers extend to drop-down list, select Maximum extend of the data

Step 7.4 (Optional)
In the Fill drop-down list, select Blue. Click OK


Step 8 (Optional)
To distinguish between cities easily, drag City from the Dimensions pane onto Color shelf in the Marks card.

Step 9
Remove the outlier in the Seattle data by hovering over the property sold at $7.7M in the view, and selecting Exclude to remove it from the view.
















Step 10
Remove the outlier in the Seattle data by hovering over the property sold at $7.7M in the view, and selecting Exclude to remove it from the view.

Step 11
Add a quick filter to the view by right-clicking Sq. Ft. in the Measures pane and selecting Show Quick Filter. Repeat this step on other Measures and Dimensions for additional desired filters.

The final view should look similar to this.