Integrity-laden social data experiment #MakeoverMonday continued into 2017 with a look at sales of the iconic Apple iPhone. My last post touched upon one tip I learned this week, but it seemed a bit lame to pass that off as the entirety of my learnings from Week 2, so here are couple more (quicker!) tips I picked up from other submissions.

1.Combining split “date” parts nicely

I noticed this viz by Steve Wood, in which his time series appeared to be some sort of cunning calculation. It wasn’t cunning, it was dead simple and another case of me over-pondering stuff!

screen-shot-2017-01-10-at-19-35-48

Nice and orderly. Bloody easy too. Just ensure that the data type of [Year] and [Quarter] is set to string, and then do the world’s easiest concatenation:

screen-shot-2017-01-10-at-19-37-16

It has an inherent chronology as Tableau is smart enough to recognise that 2008 is greater than 2007, and that the “1” in “Q1” is before the “3” in “Q3”. If you see a worse “tip” this year, let me know and I’ll lower my standards even further.

2.Date formatting and distinguishing between “eras”

Alex Barday shared his submission, and a couple of things stood out. I liked how he’d differentiated between the CEO “in charge” as each set of results were announced, and I also liked the way the dual-axis chart of line and area has that break in it, denoting the change of CEO:

Screen Shot 2017-01-10 at 19.59.26.png

After looking, it transpires that the elements are intertwined. It looks like Alex prepared his data outside Tableau, but I’ll do it in Tableau in order to try to learn something. From looking at the dates, it’s clear that Tim Cook moved into the role from Q3 2011. I can probably create a Set or Group to do what I want, but first I want to need a “proper” date field.

In Alex’s case, he prepared a field called [Quarter Date], which looked like this:

Screen Shot 2017-01-10 at 20.13.42.png

I’ve got [Year] and (sort of) [Quarter], so I was expecting to be able to use a combination of DATE and STRING functions to get to a similar position. As usual, I Googled and found another response on the Tableau Forum which was enough to help me get there – it’s a brilliant resource and I can’t recommend it enough.

There are two parts, the first trims the rightmost character from the [Quarter] field and the second applies some logic to determine what number should be allocated to the Quarter. This is based on the comments on the “Overview” tab in the source data, from which Apple’s fiscal year can be determined.

screen-shot-2017-01-10-at-20-30-07

I used INT() as the post suggested I should. Here’s the Tableau description:

screen-shot-2017-01-10-at-20-32-34

Here’s what happens if I don’t bother with it:

screen-shot-2017-01-10-at-20-34-16

The same error thrice over, because when I do things wrong, I do them REALLY wrong! INT() just standardises the datatypes in this case so I can compare like values. Last step is to combine that calculation with another to make a nice, usable date:

screen-shot-2017-01-10-at-20-36-07

With MAKEDATE() being:

screen-shot-2017-01-10-at-20-36-57

So whilst I don’t have a ‘day’ in the dataset, whacking in ’01’ as that third part of the date still works. DATE() functions really are something I need to get a better understanding of, as they’re terrifically useful.

Cool, so now we have that sorted, we can allocate a CEO to each data point. The versatility of Tableau is such that there are a bunch of ways to do it:

  1. Calculation

Screen Shot 2017-01-10 at 20.53.49.png

That’s what I did. By wrapping DATE() around the input date, I align the datatypes to enable the comparison. I’m not 100% sure I’ve got the dates perfect there, as the Fiscal Year complicates things, but that apart the output shown on the table to the left, is the expected result. Note that when you visualise this, the reason for the “gap” is obvious: it’s a continuous time period which is disrupted by the addition of the [CEO calculation] to Colour, which forces a break in the line.

Screen Shot 2017-01-10 at 20.58.51.png

2. Set

If I hadn’t figured the calculation out, I could just have done this:

Screen Shot 2017-01-10 at 21.03.53.png

The Discrete form of the date calc from earlier is plonked on Rows, and then I could just select the relevant dates and click on “Create Set”. Once done, putting the Set onto Colour achieves the same result as with the calculation.

3. Group

A third option (I’m sure there may be more!) is to Group members instead. In the image above, the Set is formed by clicking on the interlinked circles. The icon for Group is the paperclip to the left of that. When the Group is initially formed, you can Edit it, to access this screen:

screen-shot-2017-01-10-at-21-08-31

The relevance of that is the bottom-left tick box. Ticking that rolls up the remaining members into an “Other” category. This image shows the Groups contracted. You can just click the little triangle icon to expand them to reveal all members of each Group:

screen-shot-2017-01-10-at-21-09-57

That’s an important step, as if those members aren’t associated with each other, putting the Group onto Colour does this:

Screen Shot 2017-01-10 at 21.11.33.png

So they’re plotted as separate entities, rather than being regarded as one continuous “thing”. As soon as you tick that “Other” option in the Edit Group screen, you resolve this and plot a chart as per the original calculation image.

Advertisements