Scatter plots and aggregations
1. Scatter plots and aggregations
In this demo, we are going to look at the relation between GDP and Life Expectancy. To do this we will use a scatter plot. We want GDP on the x-axis and life expectancy on the y-axis. Since we want to look at the data by country, we’ll add country to the color card. Now each country has its own colr.. Let’s also only consider data from 2004 to 2014, so that we have a more recent snapshot. Something is up in our visualization. We see that life expectancy is over 400 for each country. By default Tableau thinks we want a sum of the GDP and life expectancy. It doesn’t make sense to look at the sum of those variables across 10 years, instead let’s see what the average looks like over ten years. That looks better! This drop down is a list of aggregations you can use on measures. We can use the MEDIAN instead of the Average to aggregate this data, for example. The rest aren’t as applicable to our problem. Notice how the y-axis starts at 0 but the lowest y value is around 45. We can change the start of our y-axis and now we have a better view of the different countries in this plot. Let’s say we wanted to know the number of African countries that have reached a life expectancy of more than 60 years in the past 50 years. We have two life expectancy fields to consider. The measure Life Expectancy is the actual life expectancy value. The other, Life Expectancy Grouped is a dimension that splits life expectancy into 4 ranges of categories. We will be using this one since we are focused on a range, rather than a specific value. I’ll add this life expectancy dimension to both the row and column shelf. Since these are both dimensions, we’ll need to add an aggregation to one of them to get some data points in our visualization. Let’s use count. Since we are focused on Africa, let’s filter for that. We will also make it so that color corresponds to country. Our data begins in 1960, so if we look at a data point, like this one, it means that Zimbabwe has reached an annual life expectancy of more than 60 12 times since 1960. This gets us closer to our question, but it doesn’t answer it. We want to know the number of countries, not the number of occurrences. We can fix this by selecting Count Distinct instead of count. There are 36 countries in the 60+ row, which answers our question.2. Let's practice!
Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.