Friday, October 31, 2014

Conditional Formatting w/ MIN(1)

Dan Montgomery is officially my favorite vizzer right now, with his brilliant post yesterday on using MIN(1) as a place holder for multiple measures. Check out his blog post and then come back here to learn how you can use this trick for conditional formatting.

In my example I used my college football weekly (most weeks, not this one, sorry sports fans!) data set to show the average rank, points for and points against for each of the football conferences with a team that's been in the top 25 over the course of the season. Keep going after the viz to see how I did it.

The first step was to add 3 MIN(1) place holders in the columns shelf and conference in the rows shelf:

I used a simple text label for the average ranking, and then switched the marks to gantt bars for my next two columns. The trick here is to put MIN(1) on the size shelf for your gantt bars giving you an axis of 0-3 with a gantt bar from 1-2. To make this fit your window, just change the size of your axis to be fixed from 1-2. You'll also click over to the "Tick Marks" tab and check None for both options.

Now that you have your bars, add your measure of choice to both color and label. Here is what your marks pane should look like when you're done:

Make sure you center those labels and format accordingly! You can see in the example, that my two measures are actually using two different color scales (since more points scored is good and more points against is bad) to give the effect of conditional formatting for two different measures. There you go folks. Thanks to Dan Montgomery, I am going to have lots of happy customers!

Tuesday, October 21, 2014

Week 8 - College Football Weekly Wrap-up

Finally a week that made sense! Not a lot of movement this week as only one team moved up more than 3 rankings. This week I've added the ability to see your team's or conference's movements throughout the whole season. You can also select a range of weeks to view. Check out the viz to see the scores from this week and the resulting movement.

What do you think next week's new feature should be?

Monday, October 13, 2014

College Football Weekly Wrap-up and Evolving Viz

We had another crazy one this week, with some more movement and big time playoff implications. Check out the viz below for this week's story points and slopegraph on the week's biggest games.

I've also decided that in addition to doing a weekly update I will add one feature to the weekly viz. First up, I've added all the games for the year and a parameter which allows you to pick which week you want to view on the final story point. Now you can track your favorite team through the whole season. Let me know in the comments if you have any suggestions for next week's new feature!

Monday, October 6, 2014

College Football Weekly Wrap-up

This week in college football left me no choice but to slopegraph it. Check out this handy tutorial by Ben Jones (@dataremixed) for a tutorial on throwing together your own slopegraph. Don't get any ideas, about a weekly college football wrap-up, because that's my plan! Check out the viz below for what is a completely unbiased and not at all highlighting Auburn's accomplishments and Bama's loss viz of all the movement after this week's wild college football games. Hope all you sports/viz fans enjoy my first venture in to story points.

Monday, September 22, 2014

Think Outside the Box!

I am long overdue for both a viz and a post to Viz For a Cause, so I decided to kill two birds with one stone. In August, my wife and I spent two weeks in Haiti working at an orphanage, so adoption has been at the top of my mind lately. The final viz is just below. Keep scrolling if you want details on how I built the radial menu.

TC14 actually had a pretty huge impact on this viz, specifically the “Designing Vizzes That Stop Traffic” session by (in order of appearance) Dan Montgomery’s legs (@DanRMonty), Paul Banoub (@paulbanoub), and Anya A’Hearn (@datablick). If you aren’t following these guys yet, you should really evaluate some of your life decisions. Definitely catch a replay of the session if you can get access to it. A few of the themes throughout the session were keep it simple, viz what’s important to you, cup stacking, explore other layouts besides a grid and steal like an artist (the idea for the household grid came from Dan's "Show Me the Money" viz). 

I was really intrigued by the idea of a viz that wasn’t built on a grid. Maybe it was a random idea, or maybe it was Paul's donut viz, but I really wanted to find a way to do a radial menu in Tableau. I wanted to stay away from pie charts, so a scatter-plot and a quick geometry refresher from our good friend google were my only options. For those of you that want to repeat this, here’s what you need to know.

Note: Before you begin, you'll need to decide how many points you want on your radial menu, or at least provide a parameter to let users pick.

To determine the (X,Y) coordinates of a certain number of points on a circle with a radius of one, centered on 0,0, the first step is to figure out the number of radians between each point. For those of you unfamiliar with radians (example: me), it is essentially a fancy way to measure an angle. A circle is composed of 360 degrees or 2π radians. Knowing this, you can graph a circle using the following formula, nπ/(z/2) where n is the current point being graphed (ex. The first point will be 1, the second point will be 2 and so on) and z is the total number of points, in our example it will be 40. To put this in to practice, on a 40 point circle the first point would be  determined by an angle of π/20 radians. The 37th point would be determined by an angle of 37π/20 radians.

Now that you know how to determine the angle for each point you can determine the (X,Y) coordinates using the following formulas:
X – SIN(radians)
Y – COS(radians)

Here’s how these formulas looked in Tableau (in italics below). Though you won’t see it in the final viz, I originally used a parameter to allow the user to select anywhere between 20-40 countries. This allows the circle to dynamically re-plot points if you want to vary the number of items on the menu. I really liked this feature, but in the end decided it wasn't really adding anything to the viz (as Dan would say "Keep it Simple Stupid!")

Points (z/2 from our formulas above) - [Countries to Display Parameter]/2

Note in the below that RANK_UNIQUE was used because some countries had the same number of adoptions, and you’ll need to have all numbers between 1 and 40, no room for a tie! This field just identifies which point in the circle is being graphed.

Rank (n from our formulas above) - RANK_UNIQUE(SUM([Adoptions]))

The X and Y formulas will look something like this:

X - COS([Rank]*PI()/[Points])
Y - SIN([Rank]*PI()/[Points])

These are table calcs, and after adding them to your viz, you should be computing along your dimension of choice, in my example they use country.

That's it! Place X in the columns shelf and Y in the rows shelf and your dimension (whatever is determining your points) on shape and color and remove all headers and gridlines. If you've done everything right, you should have something that looks like the screenshot below:

Another point of interest here that didn’t play a factor in the final viz but is a cool trick was my "Size" measure. This comes in handy if you are going to be changing the number of points in your circle. The formulas is, 10/[# of  Countries Parameter]. You can see in the screenshot (bottom left, Size menu) that as the user switched from 10 to 20 to 30 to 40 the value of this size measure would change from 1 to .5 to .75 to .25, allowing for larger shapes with fewer points and smaller shapes with more points.

Finally, there is the household grid. This was a HUGE thorn in my side. This was another semi-complicated math solution so I am going to cover that one in a second blog post. However, I do want to give a shout out to Dan Montgomery who came up with a really killer way to make an X by X square that would plot points dynamically based on a variable number of shapes. It was also set up in such a way that the shapes would resize to fill the entire viewing area. This solution didn’t make the final viz, but inspired the 10x10 house grid you see in the final viz. Dan is going to be doing a full write-up on the solution that he came up with so head over to his blog and check out his past posts while you wait for that!

A few other people to thank for this viz, most of all my talented and beautiful wife who provided the title logo, country shapes and the "LEARN MORE" icon. It was a much different looking dashboard before her files were added! Also special thanks to everybody at Slalom that provided input and feedback!

Family and Child icons designed by Jens Tärning from the Noun Project

Friday, March 21, 2014

NFL Fantasy Football Card Collection

I put this viz together for the Iron Viz sports competition. I wanted to capture the theme of a football card collection, focusing on the only part that us data gurus care about, the back! I'll be providing more detail in a later post on how I built this viz. I hope you enjoy it!

Tuesday, February 4, 2014

Fun with Custom Geocoding and Hawaii Frustration

Well long last it’s time to say goodbye to this ridiculous system that we called the Bowl Championship Series (BCS). For 16 years we have been almost haphazardly crowning a team that may or may not be the best team in college football as National Champion. 16 years, 16 champs and a whole lot of angry football fans (none more so than Auburn in 2004) the least I could do was put together a viz. Let’s have some fun with geocoding while we’re at it.

The most challenging part of this viz, was BY FAR, getting my data set up. Not only did I have to pull together results from the 72 BCS bowls, but I also had to manually look up the longitude/latitude for the 51 participants. Thanks to our good friends at Google, I was able to quickly find the coordinates for each of the campuses.

For a larger data set you may want to use a geocoding API. If you go the manual route, keep in mind that Tableau is going to want a “-“ sign in front of western and southern coordinates. Once, I had my coordinates together I saved them in a csv file with the structure shown below.

Getting my custom geocoding in to Tableau was as simple as navigating to Map -> Geocoding -> Import Custom Geocoding. Once the import completed I just right clicked on my “Team” dimension and changed the “Geographic Role” to the new “Teams” geographic role that I just imported.

Now by double-clicking teams, I am able to map the location of each team’s campus. I switched out the blue dots for custom shapes, based the size on Appearances / Wins / Losses, and the first layer of my map was ready to go. To color each state by conference, I simply created a dual axis map and used “Conference” as color and put "State" in the detail shelf. Tableau would not have known how to map Conference without providing State, a known geographic role. I also put "Team" on the detail shelf so that clicking on a state will pass a team value to my details worksheet (bottom left in the final viz). This way if a user misses a logo and accidentally clicks a state a value will still be passed.

Don’t panic, Hawaii fans, I didn’t forget about you. While I was terribly inconvenienced by your one BCS bowl appearance, I wasn’t going to let your distance from the contiguous states rob you of the glory that Colt Brennan and your 2008 Sugar Bowl appearance so rightly deserve. I thought about building a separate worksheet for Hawaii, but this would give me a 2nd "About Tableau Maps" footer. To work around this, I simply took a screenshot of the Tableau map and cropped Hawaii. I made sure to take my screenshot on the map after finalizing the size of the map and zoom on the final dashboard. This allowed me to make sure I had the appropriate scale. I saved my screenshot and went to the “Details” tab of the “Properties” screen for my image to find out that it was 162 x 86 pixels. I then set my screenshot up as a Background image and used two calculated fields as the X and Y axis. I set the right most value as 162 and the top value of 86. When I added the worksheet to my dashboard, I also made sure it had a width of 162 and height of 86.

The formula for my calculated fields, Longitude (Hawaii) and Latitude (Hawaii) were simply ‘118’ and ‘41’ (no quotes). You can initially make these 162 and 86 for the purposes of setting up your background image. After getting the background image showing, I determined the final values by annotating the point on the map where I wanted the logo to appear. You will also want to fix your axes to 0-162 and 0-86 and then turn off "Show Headers". You can get more detail on this trick from the "Background Images" training video available on the Tableau website.

And that was it...I added some filters, dashboard actions and a timeline at the bottom to show results by each conference. See below for the finished product. If you have any questions or suggestions for the dashboard don't hesitate to DM me @mondaymviz or leave a question in the comments below. Happy vizzing everybody!