Learn

Okay, there’s a lot to take in here, but this exercise is one of the most integral to understanding Tableau’s data language. Take your time and refer back to the chart on the right as needed.

During the Loading Data lesson, we saw how Tableau assigns different field types to data (numeric, string, geographic, etc.). Tableau also categorizes each of these fields by their role in our visuals. Tableau calls the two roles dimensions and measures.

Dimension icons are blue and represent discrete fields: categories and descriptive variables.

Measure icons are green and represent continuous fields: numbers that we can perform calculations on.

Tableau is usually pretty accurate in assigning dimensions or measures to a data type, but it’s always good to double-check. Remember when we changed the Borocode field from a number to a string? Tableau had assigned this field as a measure because it contained numbers. But we knew that the numbers represented different boroughs in New York City, and we changed the data type to a string so that Tableau will treat this variable as a dimension.

Why does this matter? Let’s walk through what happens if we let Tableau treat Borocode as a measure.

When Borocode is read as a Number and Measure, Tableau aggregates the Borocode field in the SUM() formula. (Notice that the Borocode Pill is green and has been wrapped in the SUM() formula.)

Borocode as Measure

Since the field was “numerical” and set as a measure, Tableau summed the values in that field and created a bar graph to represent the totals. This doesn’t tell us anything meaningful because it doesn’t mean anything! Manhattan has just a small bar in the graph because its Borocode is 1 rather than 4 or 5.

When we change the data type so that Tableau reads Borocode as a String and Dimension, however, Borocode now functions as an ID or label for each borough. Tableau will no longer attempt to do any calculations on this field, and we can see here how it corresponds with the variable Boroname.

Borocode as Dimension

With that sorted out, we can use the field to make a map that uses the Borocode variable to apply color to each borough, for example.

Borocode Map Color

Let’s open our workbook with the Tree Census Data so we can explore another example together.

Instructions

  1. Starting with the Tree Census data and a blank workbook, let’s look at the Tree Dbh field. It represents tree trunk diameter, measured in inches - that’s not obvious from the name, but rather something we can look up in the data dictionary. To make it clearer going forward, let’s rename it Trunk Diameter. Right-click the field and select Rename to do this.
  2. Drag the Trunk Diameter field to the Rows Shelf at the top of the window. Tableau will SUM all the values that are available. It tells us that the sum of all the trees in the dataset is just under 8 million inches in diameter - a totally useless calculation. Sum Trunk Diameter
  3. Now pull the Borocode and Boroname pills to the Columns Shelf, and we’ll see the sum of trunk diameters by borough. Sum Trunk by Borough That’s more information, but this aggregation still doesn’t tell us whether Queens has more trees, trees with larger trunks, or both. So let’s compare the difference between measures and dimensions for the “Trunk Diameter” field.
  4. Make a new sheet. Pull the Trunk Diameter field to the Rows Shelf again.
  5. This time, click the arrow on the green pill to show the dropdown menu. Dimension and Discrete Highlight Select Dimension and the Discrete and voila, you’ll see all of the trunk diameters listed out one by one. Tableau now knows to show each of these values rather than summarizing them in the SUM() formula. (We also dropped the Tree ID field to the Filter pane and selected just a handful of trees - this is a great trick for working with large datasets, and we’ll cover it in more depth very soon.)

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?