Nice post by yours truly on ATTR()
http://community.tableausoftware.com/message/286377#286377
Tag Archives: dimensions
At the Level – Unlocking the Mystery Part 1: Ordinal Calcs
There was a Tableau forums thread on At the Level awhile back where Matthew Lutton asked for an alternative explanation of this somewhat puzzling table calculation configuration option, and I’d promised I’d take a swing at it. Plus, I’ve been deep into book writing about shaping data for Tableau, and a taking a break to write about obscure table calc options sounds like fun! (Yes, I’m wired differently.)
Read on for a refresher on addressing and partitioning and my current understanding of uses of At the Level for ordinal table calculations such as INDEX() and SIZE(). Part 2 will cover LOOKUP(), and Part 3 will cover WINDOW_SUM(), RUNNING_SUM(), and R scripts. If you’re new to table calcs, read through at least the Beginning set of links in Want to Learn Table Calculations. Thanks to Alex Kerin, Richard Leeke, Dimitri Blyumin, Joe Mako, and Ross Bunker for their Tableau forum posts that have informed what you’re about to read.
The Letdown and the Pivot
The Letdown
Tableau does amazing demos. Fire up the software, connect to a data source, select a couple pills, click Show Me, boom there’s a view. Do a little drag and drop, boom, another view. Duplicate that one, boom, another view to rearrange. Within three minutes or less you can have a usable dashboard, for 200 rows of data or 200 million.
If you’ve seen those demos, the not-so-dirty little secret of Tableau is that they pretty much all start with clean, well-formatted, analytics-ready data sources. As time goes on, I’ve interacted with more and more new Tableau users who are all fired up by what they saw in the demos, and then let down when they can’t immediately do that with their own data. They’ve got to reshape the data, learn some table calcs right away, or figure out data blending to deal with differing levels of granularity, and/or put together their first ever SQL query to do a UNION or a cross product, etc. Shawn Wallwork put it this way in a forum thread back in January: “On the one hand Tableau is an incredibly easy tool to use, allowing the non-technical, non-programmers, non-analysis to explore their data and gain useful insights. Then these same people want to do something ‘simple’ like a sort, and bang they hit the Table Calculation brick wall…”
I work with nurses and doctors who are smart, highly competent people who daily make life or death decisions. Give them a page of data and they all know how to draw bar charts, line charts, and scatterplots with that data. They can compute means and medians, and with a little help get to standard deviations and more. But hand them a file of messy data and they are screwed, they end up doing a lot of copy & paste, or even printing out the file to manually type the data in a more usable format. The spreadsheet software they are used to (hello, Excel) lets them down…
…and so does Tableau.
A data analyst like myself can salivate over the prospect of getting access to our call center data and swooping and diving through hundreds of thousands of call records looking for patterns. However, the call center manager might just want to know if the outgoing reminder calls are leading to fewer missed appointments. In other words, the call center manager has a job to do, that leads to a question she wants to answer, and she doesn’t necessarily care about the tool, the process, or the need to tack on a few characters as a prefix to the medical record number to make it correspond to what comes out of the electronic medical record system; she just wants an answer to her question so she can do her job better. To the degree that the software doesn’t support her needs, there has to be something else to help her get her job done.
The Pivot
When Joe Mako and I first talked about writing a book together, our vision was to write “the book” on table calculations and advanced use cases for Tableau. We wanted (and still want) to teach people *how* to build the crazy-awesome visualizations that we’ve put together, and how they can come up with their own solutions to the seemingly-intractable and impossible problems that get posted on the Tableau forums and elsewhere. And we’ve come to realize that there is a core set of understandings about data and how Tableau approaches data that are not explicitly revealed in the software nor well-covered in existing educational materials. Here are a few examples:
- Spreadsheets can have a table of data, so do databases (we’ll leave JSON and XML data sources out of the mix for the moment). But spreadsheet tables and database tables are very different: Spreadsheet tables are very often formatted for readability by humans with merged cells and extra layers of headers that don’t make sense to computers. A single column in a spreadsheet can have many different data types and cells with many meanings, whereas databases are more rigid in their approach. We tend to assume that new users know this, and then they get confused when their data has a bunch of Null values because the Microsoft Jet driver assumed the column starting with numbers was numeric, and wiped out the text values.
- We—Tableau users who train and help other users—talk about how a certain data sets are “wide” vs. “tall”, and that tall data is (usually) better for Tableau, but we don’t really talk about what are the specific characteristics of the data and principles involved that in a way that new Tableau users who are non-data analysts can understand and apply those principles themselves to arrange their data for best use in Tableau.
- Working with Tableau, we don’t just need to know the grain of the data–what makes a unique row in the data–we also need to understand the grain of the view–the distinct combinations of values of the dimensions in the view. There can be additional grains involved when we start including features like data blending and top filters. Even “simple” aggregations get confusing when we don’t understand the data or Tableau well enough to make sense of how adding a dimension to the view can change the granularity.
Just as we can’t expect to be a brilliant painter without an understanding of the interplay between color and light, we can’t expect to be a master of Tableau without a data- and Tableau- specific set of understandings. Therefore, we’ve been pivoting our writing to have more focus on these foundational elements. When they are in place, then doing something like a self-blend to get an unfiltered data source for a Filter Action becomes conceivable and implementable.
This kind of writing takes time to research, think about, synthesize, and explain. I’ve been reading a lot of books, trawling through painfully difficult data sets, filling up pages with throw-away notes & diagrams, and always trying to keep in mind the nurses and doctors I work with, the long-time Tableau users who tell me that they still “don’t get” calculated fields in Tableau (never mind table calcs), and the folks I’m helping out on the Tableau forums. So “the book” is going slower than I’d hoped, and hopefully will be the better for it.
If you’d like a taste of this approach, I’ll be leading a hands-on workshop on pill types and granularity at this month’s Boston Tableau User Group on April 29.
Postscript #1: I’m not the only person thinking about this. Kristi Morton, Magdalena Balazinska, Dan Grossman (of the University of Washington), and Jock Mackinlay (of Tableau) have published a new paper Support the Data Enthusiast: Challenges for Next-Generation Data-Analysis Systems. I’m looking forward to what might come out of their research.
Postscript #2: This post wouldn’t have been possible without the help (whether they knew it or note) of lots of other smart people, including: Dan Murray, Shawn Wallwork, Robin Kennedy, Chris Gerrard, Jon Boeckenstedt, Gregory Lewandoski, and Noah Salvaterra. As I was writing this post, I read this quote from a Tableau user at the Bergen Record via Jewel Loree & Dustin Smith on Twitter: “Data is humbling, the more I learn, the less I know.” That’s been true for me as well!
Dimensions and Measures
More on Blue & Green pills
http://theinformationlab.co.uk/blog/2011/9/23/blue-things-and-green-things.html
Tableau automatically classifies your data based on whether it contains categorical data (dimensions) or quantitative data (measures). In general, dimensions create headers when placed in the view while measures create axes.
- Blue fields = discrete (create headers)
- Green fields = continuous (create axes)
- Bold fields = sorted
- Fields with no () are Discrete (often a dimension, not necessarily)
- Fields with AGG() or something else are aggregated
- ATTR() runs something like “if MIN(var) = MAX(var) then return var”, so it’s often the maximum value.
Discrete field always add headers to the view while continuous fields add axes to the view. This distinction exists so you can use continuous dimensions or discrete measures in the view.
Aggregate calculations are always measures
Notes from webex with Joe Mako, October 2011
Tableau is a SQL generator & displayer of results. Has a built-in pipeline of how it works – this is Joe’s best guess as of Oct 2011:
- Context Filter – creates a temp table in data source, can be global or local. Only use when we want to filter out a whole bunch of stuff, e.g. testing (maybe on admissions in readmission analysis?)
- Conditional or Top N filters
- All other filters go into WHERE clause
- Then aggregations are applied:
- Filters on aggregated fields are applied, this is returned to Tableau
- Table calcs are performed
- Final layer – filtering on table calcs
- Calculate reference lines
- Then Hide, and not displaying Null marks
Hiding/Excluding:
Null marks can be Hidden using Format pane
Values in Dimensions can be Hidden by right-click
Others get Excluded
Level of Detail Shelf:
Set to Attribute if I don’t want the Dimension to do a group by (and multiply mark results). Also useful to use aggregations to speed up processing
Reference & Averages
Reference line calculated on results is different from average calculated on table. TOTAL() function goes to underlying data, so changing a reference line from AVG() to TOTAL() will make different results
Reference lines are calculated after table calculation filters are applied
Notes from Mar 2012 WebEx w/Joe Mako
Dimensions are available to Tableau for partitioning and addressing
Aggregates return fewer marks, dimensions more. Whether aggregate or dimension affects table calcs. Discrete vs. continuous doesn’t change marks.
Aggregations will not cause partitioning, so using ATTR(Dimension) can be used to make a dimension be ignored in table calcs.
#1 Key principle in table calcs is are we working with a dimension or an aggregate.
Subtotals are based on dimension pills
What pills can be used for filtering and sorting
http://community.tableausoftware.com/message/176591#176591
Current as of Tableau 7.0, calculated fields that are strings made from aggregated calcs can’t be on Filter shelf. Solution is to use a # instead of a string
[loop category=”wikicontent” tag=”dims,measures,dimensions”]
[field title] – Added [field date]
[content]
[/loop]
Related posts:
- [loop tag=”dims,measures,dimensions,blue-pills,green-pills,blue,green,discrete,continuous,pills” exclude=”this” relation=”and” compare=”not” taxonomy=”category” value=”wikicontent”]
- [field title-link][field thumbnail-link]
[/loop]