Learn how to Recreate a Unit Chart in Tableau Utilizing Information Densification
Rodrigo Calloni posted a query on the Tableau boards final week asking how to recreate this chart in Tableau. Mahfooj Khan supplied an ideal answer for this, making a be a part of to a different sheet so as to add the extra marks wanted for this unit chart. The query got here up once more in the course of the Makeover Monday Viz Assessment hosted by Eva Murray and Sarah Barlett. On this publish, I’ll provide an alternate answer utilizing knowledge densification. This isn’t a brand new approach. I discovered this method from Joe Mako. Actually, again in 2015, Joe was variety sufficient to do a display screen share with me. He rapidly mocked up some knowledge, unioned it up utilizing Customized SQL and created a number of fields in Tableau. In a matter of minutes he had created a unit chart with a parameter to regulate the unit measurement. Then he walked me by way of the way it all labored. For anybody who’s had the pleasure of Joe strolling them by way of one thing like this in Tableau, you’ll perceive after I say, it was actually spectacular to observe him work by way of this.
In the long run, the objective is so as to add extra marks to the Tableau canvas. This may be tough, as a result of marks on a canvas are solely added in a number of methods, often from knowledge factors within the knowledge supply, including rows or columns to the information. Let’s begin with with one thing easy.
Copy the 2 rows of knowledge and header under and paste them into Tableau.
You now have a single discipline in Tableau known as Row and it solely has 2 rows of knowledge, one row with a price of 1 and one row with a price of 100. As soon as the information hundreds in Tableau:
Drag Row from Measures as much as Dimensions.
Double-click on Row so as to add it to the Rows.
You will notice the two rows of knowledge, but additionally discover the variety of marks within the backside left-hand nook. It’ll present 2 marks and a couple of rows by 1 column.
Proper-click on Row and create a bin. Set the bin measurement to 1.
Click on the New Worksheet icon to create a brand new worksheet.
Double-click on Row (bin) so as to add it to the Rows.
You will notice the 100 rows of knowledge, but additionally discover the variety of marks within the backside left-hand nook. It’ll present 100 marks and 100 rows by 1 column. You will have now created 100 rows and 100 marks from solely 2 rows of knowledge. Tableau is padding the information, beginning with the bottom quantity within the vary and ending with the best quantity. That is vital to know, as a result of we’d like the underside and high vary within the knowledge.
Proper-click on Row (bin) within the Dimensions and choose Duplicate.
Drag Row (bin) (copy) to the Columns.
Proper-click on Row (bin) (copy) and choose « Present Lacking Values ».
Change the dropdown menu within the Marks Card to sq..
NOTE: As soon as you employ a bin as soon as on a sheet, it won’t default to « Present Lacking Values », so might want to change this every time you employ the bin for knowledge densification on a brand new sheet.
There are actually 10,000 marks within the view, 100 rows by 100 columns. Once more, utilizing solely 2 rows of knowledge. To substantiate this, drag Variety of Data on Label on the Marks Card and you will note that solely the primary and final level within the grid of squares has a label.
This can be a very highly effective and helpful function, because it permits us to create marks on the canvas out of skinny air! Listed below are the ten,000 marks animated utilizing these similar two rows of knowledge.
Making a Unit Chart utilizing Information Densification
That is the chart that Rodrigo requested about recreating in Tableau. So let’s use the identical approach to recreate this chart.
Beneath is the information and headers that you could copy and paste into Tableau, or in the event you favor, you may download and import this Excel file into Tableau.
United Kingdom 72
United States 70
G7 Common 66
Comply with the identical steps as earlier than. Copy the values and paste them into Tableau (or import from the Excel hyperlink above). The values are fairly straight ahead. There are 8 nations every with a price, however I additionally added two rows of knowledge. One on the backside of the vary at 1 and one on the high vary at 100. This may give me a spread of 1 to 100 to bin the sector Rely.
Proper-click on Rely and create a bin. Set the bin measurement to 1.
Drag Rely (bin) to Columns. You now have 1,000 marks, 100 columns by 10 rows (8 nations and a couple of further rows that I added).
Change the dropdown menu within the Marks Card to sq..
Choose Whole View from the highest menu to pressure the view into your entire canvas.
You must now have a view that appears like this.
Formatting the Unit Chart
The essential unit chart is full, however now we have to format it.
Proper-click on Backside within the Nation column and choose Cover.
Proper-click on Prime within the Nation column and choose Cover.
Proper-click on the X-Axis on the high and choose Take away Header
Coloring and labeling this chart is a bit tough. Bear in mind, although you’ve gotten 800 marks within the view (100 columns by 8 nations), there are nonetheless solely two rows of knowledge. Nonetheless, there may be one perform that can assist on this case; the INDEX() perform. Create a calculated discipline for Index.
Calculated Discipline: Index
Drag Index to Label and you will note Tableau rely from 1 to 100 for every row of knowledge, although there is just one worth for Rely in every row. The sum(Rely) is NULL in all the different columns. We are going to leverage this to format our colours.
Create a calculated discipline:
Calculated Discipline: Shade
Method: isnull(RUNNING_SUM(Sum([Count]))) or index() = sum([Count])
The colour formulation does a verify to see if the operating sum of the rely is NULL or if the index is the same as the sum of the rely. This may produce a True/NULL that we are able to use on shade.
Drag shade to Shade on the Marks Card.
The bars are actually coloured in True/NULL. You possibly can reformat the colours as desired and in lots of instances you is perhaps achieved right here. Within the authentic view, the G7 Common is a special shade than the remainder, so we might want to add Nations to the colour.
Drag Nation to Element on the Marks Card.
Click on the Element icon to the left of Nation on the Marks Playing cards and alter it from Element to Shade.
Double-click on the colour legend and format the NULLs to grey, the Nations to Purple and the G7 Common to blue. You should use your SHIFT key within the shade menu to pick your entire vary and alter them directly.
I used a form of a block as an alternative of a sq.. You possibly can download my block shape here and add it to your Tableau Repository (sometimes saved in /My Paperwork/My Tableau Respository/Shapes/…).
The ultimate chart ought to appear like this.
My Tableau workbook is available to download from Tableau Public.