Table Structure for Tableau - charts

I have a query regarding the table structure for the pie chart on Tableau.
I have below 2 table structures and am not sure which one is more apt for tableau to arrive at a pie chart .
For example I wish to see the percentage of each metric over a particular date contributing towards the total. May be the representation is a pie chart or some other chart. Please suggest me which table lay out works out well for my requirement.
Note : I have done all my calculations to arrive at the total in my database table itself.
Could some one please help me out.Thanks!
Table 1 :
Table2 :

Pie charts first take a series of data and sum the total. Then they calculate the percent of each element of the series and create a pie slice with a unique color. To make a pie chart, you need one measure (the category or label) and one dimension (the amount of that category).
If you need to see how one is made, I would suggest downloading an example workbook and then going to the pie chart sheet. One example is here.
Here is how it looks when set up in Tableau.
Personal note: Despite the name, pie charts are not that delicious. Here is advice from Tableau themselves. And here is something I made up to express my feelings.

Relating to the topic of pie charts, and how to best represent data where contributions to a whole are of interest, I would recommend bullet graphs as well. Here are two papers by Stephen Few that could be of interest:
Save the Pies for Dessert
http://www.perceptualedge.com/articles/08-21-07.pdf
Bullet Graph Design Specification
http://www.perceptualedge.com/articles/misc/Bullet_Graph_Design_Spec.pdf
And, to answer your question on data preparation for Tableau, it looks like the second table would be more appropriate. Here's a good KB for preparing data for analysis, note the last section on the Tableau Reshaper tool for Excel...can save a ton of time.
Preparing Excel Files for Analysis
http://kb.tableausoftware.com/articles/knowledgebase/preparing-excel-files-analysis

Related

How do I plot one measure per axis in Tableau?

I have a problem that I have reduced to its essence with the following CSV file. Imagine we're a company that sells potatos and apples, and each customer is assigned a potato-class and an apple-class.
What I want is to plot the sales according to class - so apple sales by apple class and potato sales by potato class, in one diagram. Dragging all the measures into a workheet, I get this:
So I would like an overlay of the top left and bottom right classes.
If I combine everything into one diagram via dual axis, I get this:
So Tableau is plotting potato sales and apple sales on both the potato and the apple class axis, creating four dots per class where I want two.
Does anyone have an idea on how to basically assign one measure to one axis instead of both measures to both axes? (Hiding the "wrong" dots would also be fine).
Also, I realize that pivoting the dataset to have fields "sales", "class" and "product" would solve the problem, but reality is of course far more complicated than this toy example and it's just not feasible.
Thanks!
You'll likely have an easier time if you reshape your data first, say to have the following columns "Customer,Item,Class,Amount" -- so each row in your original data set would yield 2 rows in the transformed version of your data set. Tableau Prep can make those types of transformations easy (and repeatable), but it is possible to do something similar in Tableau Desktop alone (using a self-union and some calculated fields).
So the first 2 lines might be:
Customer,Item,Class,Amount
1,"Apple",1,2
1,"Potato",1,4
Either way make sure Class is treated as a dimension in Tableau.
Data wranglers often call this a tall format instead of a wide format.

Tableau Percent Difference Between Week

I am trying to display a graph that shows the increase or decrease in percentage of calls from each country over time (sample data and desired output below). This is intended to answer the question, "Has the proportion of calls within the USA compared to the others gone up or down in the past week?", not to be confused with answering the question if USA has just seen more calls.
In the example below, I am looking for a bar chart that shows increases/decreases for all of the countries (x-axis = country, y-axis = percent difference)
I understand how to do this based on a simple change in count, but am struggling to look at this as percent of the total.
Sounds like you want to do a Table Calc on a table calc. No problems to do this. I suggest creating the first calculated field and saving it as a new calculation. Then use that field within your final table calculation.
If you're creating the table calculation using the Quick Table Calculation, double click in the pill to see the underlying formula - you can copy this out and paste into a new calculated field.
You are also able to set the "Compute Using" separately using this method, which may be useful in this example.

How do I sort this scatter plot?

I would like to sort this scatter plot, which is summarized with a Band that includes Minimum, Average, and Maximum.
I would like to sort it in 2 ways:
by Average
by Widest Range (ie difference between Minimum and Maximum values)
Tableau Public workbook
If you can't view this or I'm not allowed to post external resources on stackoverflow, then perhaps you can show me on this screenshot what I would click to get started on the following sort
Also, bonus question, is there a way to create a control for the user to toggle between the 2 sort methods in the same chart? Or do I have to duplicate the chart with a different sort type for each?
One note is that I only have Tableau Public version since I'm evaluating the product. Until I get a paid version, I can't open a workbook file unless you publish it to Tableau Public cloud. But rather than give me the workbook answer, I would just appreciate it if you gave me instructions to do this as this is more of a learning exercise.
Thanks!
Somewhat unfortunately, you'll have to replicate the min,avg,max by creating 3 calculated fields. Tableau cannot operate on the values placed on the view via reference lines.
These calculations might look something like these:
{Fixed [Cwe]: Min([Cvss Score])}
~
{Fixed [Cwe]: Avg([Cvss Score])}
~
{Fixed [Cwe]: Max([Cvss Score])}
In general, from there, you should pretty easily be able to apply them to the view and sort. Average will be easy. The difference between Min and Max will just need a subtracting calculated field to sort by. Once they're on the view, I'd put them as a dimension (column) to verify that the numbers look correct.
Take note that LOD calculations take place before filtering, so you'll want to put the Cvss filter you have there 'on context' by right clicking it and clicking 'add to context'
Here is how I would complete the sorts:
Starting with all the above calculations on 'Rows' and ensuring that they are 'Dimensions' (Blue).
After right clicking "Sort..." on [Sub-Category] on 'Rows'. Select which field to sort by.
From there, the calculated fields can be taken off the rows column. (They were only there in the first place to ensure that you could check that the sorts took place. They don't actually need to have been there in the first place.)

Tableau: How to show two measures from different data sources in the same chart (without blending)

Currently I have a chart that displays monthly GA visitors. This data comes from a GA table in the DB (Table 1)
I have a separate data source for purchases (Table 2). I have a chart that shows # of monthly purchases, but I'd like to combine these into one chart so I can show a monthly conversion rate.
Tableau keeps prompting me to blend data and I don't want to do that (I don't think). Tableau seems really unintuitive at times.
Please see the screenshot below. The numbers in red are what I'm looking for. They need to pulled on the same dates as the GA data. I can derive the conversion % from there.
Thank you! Tried a bunch of stuff but getting nowhere.

Multiply all rows in a Tableau table chart

This seems pretty simple, but I can't seem to find a way to do this.
I need to multiply all rows in a chart - or all columns, whichever is easiest. AKA. I am looking for something like the product() function in Excel.
Any ideas on how to accomplish this?
EDIT: Row values may change, so this needs to be a dynamic calculation. Like a function to aggregate all values into a product of the values.
A calculated field can be created with: sum([Sales])*PREVIOUS_VALUE(1)
This gives the running product. Then, that field can be inserted into the table.
You can certainly create a calculated field that will multiply various columns together. Something along the lines of [Column1] * [Column2] * [Column3] will generate a new calculated measure that is the product of all three columns.
That being said, if you're doing that much data manipulation within Tableau, you should probably be giving some hard thought as to why that's necessary. While calculations are certainly possible and new Tableau 9 features such as level of detail functions make doing calcs on measures not present in your viz easier, Tableau is primarily a data presentation layer. Data manipulation apart from simple calcs and pivot/unpivot operations should be done upstream. Doing advanced manipulations within Tableau, while sometimes/often possible, can be very hard to debug and reproduce.