In my last post, I couldn’t figure out how to achieve the basic chart structure of the Data School Gym Challenge, where Andy Kriebel‘s final dashboard ended up looking like this:

Screen Shot 2016-08-18 at 19.31.48

It wasn’t even the layout of the dashboard with its Floating objects and custom horizontal / vertical line .pngs that I was concerned about, I just couldn’t suss out the basics of a Gantt Bar where a shaded “duration” bar is overlaid with Gantt markers to denote specific marks.

No amount of head-scratching, research or swearing resolved it last night, so I uninstalled Tableau Public this evening and downloaded it fresh to get 10.0, seeing as it didn’t seem to want to update from 9.3. That enabled me to download and access Andy’s .twbx to see where I was going wrong.

First up, I went to one of Andy’s sheets to see how his Gantt was created. I knew it was a dual-axis of some sort, but it was the shaded bar that caused me issues. I immediately noticed this difference on the Measure Values pill:

Screen Shot 2016-08-18 at 19.41.09

OK. So what are these Cons, Lib and Mod Measures, and why are they there? The associated calculated fields are just taking the original datasets’ Conservative, Liberal and Moderate fields, and multiplying them by 100:

Screen Shot 2016-08-18 at 19.42.30

So why is that required? Look at this image of the source data:

Screen Shot 2016-08-18 at 19.43.47

See how the original Conservative shows as 35% and the Cons calc is 35.0000? See why Andy did that?

I didn’t.

So I delved further into his chart to see why the initial Gantt element plotted 3 marks based on the 3 calculated fields rather than the originals, and how the shaded area was created. Curiously, I started at the end. Here’s how the shaded area is created on Andy’s viz:

Screen Shot 2016-08-18 at 19.53.41

It’s the Size that is relevant here. What is this Cons-Lib calculation?

Screen Shot 2016-08-18 at 19.53.56

It’s what it says it is. Why is it this? Because that is the range we need to plot for the shaded area, as the Conservative voters were always the Maximum State by State, and Liberals were always the Minimum State by State in the 2016 Republican Primary. As Liberals are always the Minimum vote share, you shove the SUM(Liberal) on the secondary axis as it is from that point that you need to size the shaded area.

Same approach works for the Democratic Primary, where you just plonk SUM(Conservative) down as the secondary axis as they always represent the lowest vote share from which to size the shaded area. You then sync it and drag a calc to the Size card on the secondary axis which represents the consistent trend of the majority of voters being Liberal, and minority being Conservative in that Primary. OK, this makes sense.

But what about the General Election itself, where the distribution of votes isn’t so linear and North Carolina appears to buck the general trend?

Screen Shot 2016-08-18 at 20.13.31

Here, it is clear that the Moderate voters with one exception represent the MAX and Liberals always represent the MIN. Why does the SUM(Mod-Lib) calculation on Size work in all cases, when it isn’t the case for all States (North Carolina)?

I tried it without using the Cons, Mob and Lib calculations on the initial axis:

Screen Shot 2016-08-18 at 20.24.21

The calculation on Size was just:

Screen Shot 2016-08-18 at 20.26.03

It fails, and I expected to, as the shading for North Carolina is clearly shown to represent the gap from Moderate to Liberal, with the unshaded section just being the gap from Conservative to Moderate as it falls out of the scope of the calculation.

I. Just. Don’t. Get. It! I walked through it step-by-step and the same happened. I’m confused. Have I made an assumption without paying attention?

Alright. Let’s park that, and this time I’ll exactly recreate Andy’s approach, shelving the fact that I don’t “get it” at this point. I closed the workbook, started afresh and connected to the source data again, with the sole intention of recreating that tricky General Election worksheet.

I diligently recreated the Cons, Lib and Mod calcs and recreated the basic structure of the chart.

Screen Shot 2016-08-18 at 20.51.31

All good so far. Now what about this annoying final stage? Sometimes when you realise how things are done, it’s extraordinarily frustrating to admit that you missed something simple. I get that every week so can deal with it to an extent, but it’s still a facepalm every time. Look at Andy’s fricking calculation on the Size card:

Screen Shot 2016-08-18 at 20.54.17

That’s right. It has a simple logic statement to cater for the fact that in the exceptional case of North Carolina, the calc will work on the basis of the fact that for North Carolina, the range of the shaded area needs to be from the MIN where Liberal (as with all) is the lower vote share, but where Conservative voters were the majority (whereas for all other States, Moderates were dominant). Balls. Missed another simple thing.

Once remedied, I could easily recreate the three separate charts without the need to refer to Andy’s workbook, and I’ll worry about the floating and formatting another day.