Thursday, October 30, 2014

My Favorite Tableau Trick For Work: MIN(1)

Many of us found +Tableau Software from the work that we do in our day jobs, and have since taken our passions to our free time.  When given the ability to build visualizations we're passionate about, people come up with creative solutions like Anya A'Hearn's Stairs Of The CityKK Molugu's Playoff Quarterback TouchdownsRussell Spangler's Bacon Viz (and WAY too many more to mention).  


In our day jobs, there is much less room to be creative and more of a need to be direct.  As a result, designs usually involve displaying more numbers than visualizations.  And while there are best practices by Nelson Davis about when to use numbers and when to use visuals, numbers end up more often than us 'creative types' would prefer.  


You can still let loose your creative side even when displaying numbers.  My personal favorite trick is the MIN(Number of Records) trick, or simply MIN(1).  You can create the field like so, and then set the default aggregation to MIN

You can create a new field or simply use 'Number of Records' that is in default Tableau
Set the default aggregation to Minimum to make ongoing use easier

And get results like this


MIN(1) is a calculated field that you can create that give you a measure in your worksheet that acts as a place holder for other measures.  You can then add whatever measure, or combination of measures, to the text charm of your field and display that in a very organized fashion.


An example then.

Normally, if we wanted to show a series of numbers on a sheet, we put 'Measure Names' in the rows, 'Measure Values' in the Text, and it would look something like this....

But if you want to color just the Profit Margin line, based on a set percentage of 20%, you can't.  An attempt would make your result looks something like this...

However, using MIN(1), you can set placeholders for each of the measures and then analyze them however you want.  Here's the same sheet, redesigned....

Notice how I've dragged four copies of 1 on the screen that show up as MIN(1) because that is the default aggregation I have set.  Every row is now on a scale of 0-2, with 1 dead in the middle, but more importantly it provides it's own measure to color, size, give level of detail, etc.  Now I can just color the Profit Margin line by itself and leave the other lines alone.


What about combination charts, a chart that shows both bars and text.  If we try the traditional example again, we get something like this.

While we are able to achieve both text and charts, the text is aligning to the value it represents thus making it hard to read the numbers.  Now let's' rebuild this using MIN(1)

The result is that the numbers are all aligned for each metric, a bar chart is in the middle for the specific metric worth highlighting, they are still separate measures which allows us to edit color, size, and level of detail, with an overall clean look.

UPDATE:  Steven Carter wrote a post to do filled cell conditional formatting with text.  Forcing the cell lengths and using Gantt charts you can now have a look that is similar to Excel (for helping people transition away from it)
Way to go Steven!
In addition in both cases, because this is all done in 1 chart there is one query back to the data source, and if you have too many values to fit on the screen, you can SCROLL (!!!!!) and know that one scroll will move all of the fields necessary.


I was working with a customer where on a dashboard, we wanted a way to highlight the number of alerts that people needed to pay attention to.  To make it stand out, I put the number in a text box with a highlighted background and a border. 

Using MIN(1) as a bar chart and setting the range from 0 to 1, I can set the border on the bar chart, change the background color based on any value you want.  All of this is happening while also never having to worry about the bar chart range.  Here's what the sheet looks like.


If you're building a dashboard and need to display numbers in some capacity, MIN(1) is another tool in your Swiss Army Knife of Tableau skills.  It allows you clean layouts but with all of the customization we've come to know and love using Tableau. 

Please comment or tweet at me (@DanRMonty) with other ways you've found you can use MIN(1)!

DISCLAIMER: you do need to have text fields on your dashboard now to label your measures (you can put them in a container to make it easier to manage).  You can see this in the dashboard above.

Sunday, September 28, 2014

How to auto-scale and auto-arrange shapes/visuals in Tableau

I ran into a unique problem when I built my sports viz a while back.  I had this idea to show a picture for every value of a metric.  However, when I sized the sheet to fit the maximum allowable values, any less than the maximum showed a large amount of white space. (I've since updated the sports viz with this article's trick)  

Then my friend Steven Carter released his viz titled "The Adoption Gap" (and subsequently won Viz of the Day) where he took my picture idea to the next level with his household grid.  Using formulas, he was able to set a grid, and then show a gradually filled in house to represent the number of adoptions needed.

AND THEN Chris Luv released his viz explaining INDEX() and SIZE(), two incredibly valuable table calculations in tableau to determine size and position of a point.  Using INDEX and SIZE, he was able to completely recalculate row and column values on the fly, removing a lot of constraints Steven and I had come up with. His final viz was so good, it made me rethink my entire design.

Having been inspired by a number of sources, I present a fourth option (very close to Chris' solution but with a slight tweak). I have build a sample viz that shows how to use formulas and table calculations to autoscale and autoalign shapes (or visualizations as Chris will show) to a grid based on how many values are available. Check out the final result below.


In my original sports viz, I was unaware that Tableau will do the sizing and arranging work for you if you have rows and columns that the images will fit in.  So here's how to use a unique ID column to auto generate the links we need

1) Create 'Y Axis' Field


So what is going on here?  The idea is that as the number of objects to display is usually best represented in equal rows and columns.  Thus, the number of rows we want (represented on the Y axis) should be the square root of the objects/dimension values.  The INDEX() -1 offsets the values so they continue to line up instead of shifting out.

2)  Create 'X Axis' Field


This one is a bit more complicated, but is to continue to hit on the idea of displaying equal number of rows and columns.  So with the 'Y Axis' figuring out a bucket for values for the row, the X axis needs to reassign the ID for the value so that the rows start over successfully.

So what this formula is doing is taking the current index value, subtracting the y axis bucket multiplied by the bucket value to always reestablish the new set of rows.

3) Build sheet and assign shapes

The setup is as follows
a) [ID] goes in the details
b) 'X Axis' goes on the columns shelf, convert to discrete
c) 'Y Axis' goes on the rows shelf, convert to discrete
d) 'Y Axis' and 'X Axis' should be addressing every field (see second screenshot for the how to)
a), b), & c)
Let me know if this is helpful or if you have any questions.  Thank you!

Wednesday, September 10, 2014

How to Embed Streaming Web Content in Tableau

Tableau is a great, if not the best, tool for building data visualizations.  But what the tool also includes is the ability to display content from the internet right in your viz!  Here is the how to for streaming that content, and I will be using my "Weird Al" viz as the template for this.

1. Build the Data Set

If you want an interactive viz that dynamically displays different web content, you first need to build a data set that shows the different components you want to stream.  In the case of "Weird Al", I wanted to stream his individual songs and albums, so I went to Wikipedia for his discography and copied it into a spreadsheet. 

  • Just like any other Viz, a content viz is still data driven, so be sure you have the most robust/cleanest data you can work with
Album data with various attributes
Song data with various attributes

2. Gather the web links

In a "How-To" guide that allowed me to even build out this idea, +Ben Jones wrote about embedding YouTube into Tableau.  The key is that regardless of your content source (YouTube, Spotify, Soundcloud, etc), you want to find the 'embed' url to leverage in your dashboard.  In Spotify, these can be found by right clicking on a song and selecting 'Copy Embed Code'
The resulting code will look something like this, and the URL that you want is highlighted in yellow: <iframe src="" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>

That URL can be copied to your Excel data like so
It is very important to line up the correct URL to the correct record in the data

  • Regardless of web source (YouTube, Spotify, Soundcloud, etc), identify the Embed url the desired content, and include that in your data source

3. Build a Dashboard That Will Stream the Web Content

In your viz, design your dashboard however you wish.  For the "Weird Al" viz, I wanted people to be able to select an image of the original artist and then be able to play that song.  Here is what the resulting Tableau sheet looks like
The field containing the URL needs to be in the details of the worksheet
In the dashboard, add the worksheet as well as a Web Page item.

After adding Web Page, select 'OK' to continue.  It's okay to leave it blank
With the URL is part of the details, the URL can be triggered from the dashboard via an action.
Add the sheet to a dashboard, then select Dashboard -> Action
The type of Action to add is a URL action
Check off the sheets you want the action to work from, and then select the field that contains the URL you wish to stream.
Select the arrow, then select the field that has the URL
After that, you can now stream by making a selection on the specified sheets (in this case Parody Song - Images and Parody Song - Lists) and the url listed in the data will appear in the web part.

  • After placing a Web Page part on your dashboard, you can use a URL Dashboard Action to pull the streaming content from the selected data point.

BONUS POINT. Custom Hyperlink Text

In the section above, the url action was delivered using a 'Select' URL action.  That means when a component of the specific worksheet is clicked on then the action will take place.

Tableau also offered 'Menu' actions, meaning that when you hover a specific data point, a URL link appears in the tooltip for you to select.  The advantage here is that you can variablize the text in the tool tip.  For example, the links could looks something like this...

This is easy enough to do.  Start with the URL action just like before

Select the 'Menu' action, and whatever you put in the Name will be what's displayed to the user.  You can even variablize the name by including values from the data, in this case Song title.

  • Actions can be selection or text based.  The text based actions, however, can be customized to display a message to the user relevant to the data point they are hovering on.

Conclusion: Steaming Web Content is Easy and Awesome in Tableau!
So there you have it, a breakdown of the how to embed steaming web content in your Tableau dashboard.  Check out the original viz for the interactive experience.

Making a Viz That Stops Traffic

I was honored to be asked to speak at +Tableau Software's Customer Conference this year with the extremely talented +Anya A'Hearn and +Paul Banoub at a feature presentation entitled "Making a Viz That Stops Traffic" hosted by the ever amazing +Jewel Loree.  I gave the following presentation, which compiles my thoughts and process for how I approach building dashboards and visualizations.

Enjoy and feel free to comment to let me know your thoughts.  Thank you.

Thursday, July 31, 2014

Weird Al FTW

My enthusiasm for "Weird Al" started back in 1996 when I was at a friends house and he played the "Bad Hair Day" album for me.  I didn't know any of the regular songs, but I thought everything he did was super funny and also made me dance around the house.  As time went on, I was able to see him live twice (a must do for anyone) and somehow at every stage of life, I've found other people who enjoy listening to Al as well.  

To celebrate his latest album, "Mandatory Fun" and it's climb to #1 on the Billboard charts, I have created  a viz to show off how much Al has accomplished and give the user a way to interact with his music like never before.  

Hope you enjoy!

Thursday, April 24, 2014

Tableau Data Blending with No Common Dimensions

Sometimes when you're working with data, there is a need to compare datasets that don't really have anything in common.  This issue came up with my Sports Viz Show Me The Money: I had a dataset that contained the top 100 earning athletes in 2013 and I wanted to show what their pay could buy for them at an individual item level with out creating an unnecessary Cartesian product..  
Athlete data: a single row per athlete
As Gru would say: Light bulb!  If I create a data set containing a row for each purchasable item repeated the maximum amount of times it would appear (aka the number of times the top earning athlete, in this case Tiger Woods, would be able to purchase it), then I could write a calculated field that blended the two sources and did my filtering for me.

Stuff to buy data: note there is no column mentioning athlete
Doing this gave me two data sets: one that was 100 rows deep and the other just over 5,000 rows deep.

Next, after bringing in both data sets into Tableau, I created a cross dataset calculated field on the 'Stuff to Purchase' dataset that would allow me to filter out when the number of items exceeded the athletes pay.
running_sum(sum([Cost]))<=sum([Forbes 100 Athletes].[Pay $])
This way when I add the purchase able items at a data level, it will continue to referenced the accumulated value of the purchases and restrict them to only total that is less than the salary of the specified athlete.

Finally, I added
- RowID into the details
- 'How Many' true false filter to the filter section
    - IMPORTANT: Change the 'Compute Using' to use RowID
- Add the purchase category and item to the filter section
- Added the object's description to shape
- Filtered it for the specified athlete (from the secondary source).
   - This ultimately ended up being a quick filter that allowed me to select different athletes

Now I had my sheet that showed each of the items that the person could buy.
 If I had joined them ahead of time, I would have had a Cartesian product of over 160,000 rows!  This not only saved me data space, but also cut down on the data prep I needed to get dashboard built.  

So the answer all along (to the question that was never asked) was yes, it will blend...even if there are no common dimensions.  Let me know if you have any other questions and feel free to comment.  Thank you!

Wednesday, March 19, 2014

Ready, Set, #IronViz

March is Sports Blogging Month at +Tableau Software.  If you have ever visited my blog before, you know that's definitely the kind of blogging I can get behind (all but 2 of my vizzes have related to sports).

So here is my official submission for the sports blogging month and #IronViz sports blogging challenge.  Forbes publishes a list of the top 100 earning athletes and in addition to finding insight into HOW these athletes earn their money (endorsements vs salary/winnings), I tried to put a picture around what exactly $78 million dollars translates to (answer: a lot!). 

So enjoy and feel free to comment or let me know if you have any questions.  Thanks!

Wednesday, March 12, 2014

PowerShell and Tableau Server: Automating User Creation and Group Population

UPDATE: I corrected the link to enable secure password storage and recovery in PowerShell.  Apologies for the incorrect link.

As long as Tableau Server runs on Windows machines, an admin's best friend is to leverage PowerShell to automate some everyday tasks.  There have been other great articles on combining Tableau and PowerShell, like Automated PDF Email Distribution by the talented folks at +InterWorks.  

But what, for whatever reason, you need to take down a Tableau Server configured for Active Directory Authentication, restore it as Local Authentication, and recreate the existing users (because the users from a directory will not translate to local authentication).  

Why it just so happens that I have a sample script for that!  To do this, you will need the following items
  • An admin login and password for Tableau server 
  • A csv file with the existing users, their names, and potentially email address'
  • A csv file with the groups and their users
    • Both csv's can be generated using data from the PostgreSQL.  Read here for how to enable that (and search the forums for how to enable read access for all tables/views, not just the default ones!!!)
  • A will and desire to WIN! or just take an otherwise tedious task off your plate.
CLICK HERE for a working powershell script and sample documents.  This method stores the password in the script, though there is a secure method of accomplishing this listed here.

Import-CSV: A very power cmdlet to read data from a csv and allow the script to 'play with the results'
select-object: Manipulate the results of a data set (perhaps coming from Import-CSV), much like you would with SQL
.\: This forces PowerShell to run traditional command prompt commands without prompting the user to accept it
foreach: Exact what the name suggests, iterate through every line of a dataset and run a series of commands

Thanks everyone.  Take care and let me know if you have any questions.

Thursday, February 27, 2014

#VizYourLife: Moving to San Francisco

Not that anyone's holding their breath, but it's been over a month since I posted any content on my blog.  In that time, I did the following

  • Said goodbye to the city I've lived in for 28 years (minus college)
  • Packed up almost of my belongings that would fit into my car.
  • Drove across the country to San Francisco
  • Started working the day after I've arrived
  • Slept or looked for an apartment nearly every minute I haven't been working
So needless to say I have been very busy, or just exhausted enough that I've put the blog on the back burner. 

However, here are some viz's based on my last month.

This is my 3 (really 4) day drive from Chicago to the Bay, stopping Nebraska, Utah, and Sacramento
California is currently experiencing a crazy drought, though it was down pouring when I got into Tahoe
Chicago has more negative equity...
...and SF is just insanely expensive.

Chicago real estate is in higher foreclosure, California real estate is just insanely expensive.

And while Chicagoans are very proud of their food, San Francisco is not as hippie-dippie vegan/vegetarian as people seem to think they are.

Pizza, hot dogs, chili...yeah that sounds right
A burger right off the bat, follow by a Cioppino, which looks like an awesome seafood dish.

In short, sorry for the delays.  I'm still getting settled but I'm so glad to be out in the Bay and looking forward to blogging and meeting up with Tableau users.  

Take care, everyone.


Wednesday, January 22, 2014

New To Data Blogging: 3 Lessons 3 Months In

When +Ben Jones announced Data Blogging Month, I thought about if I should write anything on the subject or not.  I've only started blogging about 3 months ago, so I'm still very new to this space.  Plus, after learning more about the Tableau Public community, I'm continually humbled by what I see the community put out and feel like I always have things I can be learning.

But this may also be an opportunity to turn an apparent weakness into a strength: I have the perspective of someone new to the game who is trying to establish a voice and presence while encountering some early bumps in the road.  I've probably learned more in the past 3 months than I had in my previous 3 years of using Tableau (kicked off with a schooling by Nelson Davis), and maybe these are the same things that others are going through in their early experience of getting into +Tableau Software Blogging.

1. The Story Being Told Is Paramount

This may seem like the most fundamental concept of data visualization, but is also the very thing that is easiest to lose sight of.  In the midst of getting your worksheet perfect and leveraging Tableau's capabilities (not to mention thinking about getting views/retweets/reposts), it becomes very easy to resort to "this will look cool" or "look at how smart I am" types of worksheets that ultimately end up confusing the user and turning people away from the viz...  

...and the tool won't get in your way from doing it.  Tableau is so developer friendly, there is no disincentive to complicate.  I can't count the number of times I've been building and thought along the lines of "It'll look better when I color the line with this metric, or size it with another metrics, or throw in a table calc".  Only later, when showing it to someone and they can't understand what in the hell is going on, does this come back to bite you.

The story you are telling grounds you.  Even when you are absolutely lost, are suffering writers block, or aren't feeling creative, the story you are telling is what re-engages and brings you back to focus.  An engaging story, even if it doesn't have as many bells and whistles, is will keep users looking and sharing.  Don't be a Sheldon and push people away with how smart you think you are.

2. Great Design Takes Time (And Lots Of Iteration)

A goal in the next month is to film how long it takes me to make a dashboard that I publish on Tableau Public.  The idea being that even with the ability to create insight in 3 minutes, I would guess that I spend about 15-30 HOURS of development, and countless more hours even thinking about it, before I get to a Viz that I post up.  The dashboards that win Viz of the Day probably go through the later process more so than the former process.

I may be on the slower end (it's not really something I've polled other developers about), but all of that time is spent in a number of different ways
  • I probably create 8-12 worksheets to investigate my data before getting to the 3-4 worksheets in my final viz
  • I'll wish I had more data to answer a question, so then I need to research and find that additional data and bring it into my workbook
  • I'll play with the layout of my dashboard in numerous different combinations
  • I add too much content and now I need to pear it down
  • If there's text, I'm constantly rewording to hit the message while taking up as little space as I can 
  • I'll mess with different color pallets to see if there are better color combinations (FYI: Cyclic is the bomb!)
  • I share drafts with peers and iterate based on their notes 
It may be inefficient, but I reassure myself with a quote from the #TCC13 keynote: "The great discoverers are jazz artists— they combine logic with intuition." Discoverers feel, they chase, they shift perspectives and they relate different ideas."  My overall time may be longer than others, but I would put money that the great final products didn't come together exactly as you see them.  Rather, they were the result of exploration, revision, and polish.

3. Your Blog Is About You, Not Your Audience

The beautiful thing about the internet is the ability to instantly share your thoughts and receive feedback with a global audience in near real time.  I can publish a post, tweet it, and start hearing from others in less than 10 minutes.  That tight feedback loop can dig into our own image of ourself.  Early on, I fell into the trap of being crushed when I didn't instantly have thousands of retweets or get a million comments.  Even after winning Viz of the Day with my Mike Ditka Viz, life moved on and the next day there was a new Viz of the Day (won by my very talented colleague +Peter Gilks none the less).

Now, I'm not saying that being recognized isn't a big deal.  Winning Viz of the Day was a huge honor; something I'm still very proud of and grateful for.  I'll never forget jumping up and down when someone who I didn't know (ended up being +Steph Stradley) retweeted one of my first posts.  But getting lost in the idea that "everything I do has to win/be retweeted/get views" became more important than "design something that efficiently tells a story and relays my passion for a topic".

Refocusing my efforts back to the process of telling stories that I'm passionate about, and less about the results of those efforts has made the experience enjoyable again.  I still reach out for feedback from my talented colleagues at +Slalom Consulting and I look at what the +Tableau Software community, especially the Tableau Zen Masters, are producing (my current favorite being +Kelly Martin and her VizCandy blog) to continue to refine my skills.  But at the end of the day, my blog is mine; something I do to share my interests in a way that maximizes/sharpens not only my Tableau skills, but also my design skills.


Maybe I'm wrong.  Maybe I'm the only guy who gets lost in rabbit holes of features instead of story.  Maybe I'm the only one who takes forever to get my viz's together.  Maybe I'm the only self deprecating narcissist on the internet.  Either way, these all were lessons that I had to learn (and continue to relearn) to be confident and okay with putting myself and my passions out for the world to look at (or ignore).  I've improved my Tableau skills beyond where they were before I started and I'm looking forward to what the Tableau Public community (myself included) can produce in the time to come.  Thank you.

Tuesday, January 14, 2014

Defense vs Offense: A Chicago Bears Coaching Transition

In January 2013, the +Chicago Bears  made the largest coaching philosophy transition when they fired Lovie Smith after a 10-6 season and hired Marc Trestman from the CFL.  

How did their back-to-back seasons compare? Check out the viz below for more information.

UPDATE: As pointed out by my brother +Matt Montgomery , there are two other reasons to be excited for the +Chicago Bears that I will try to incorporate into the viz.
1. Top Offenses > Top Defenses via AdvancedNFLStats
2. Offense is more consistent than Defense, year to year via FootballOutsiders