(Addendum: Jonathan Drummey has a much better Tableau-only solution that I missed from his presentation. I only caught later part of the presentation. You might ask him about it if you know him.)

In a recent presentation, Tableau visionary HOF Jonathan Drummey talked about a solution for a variable row heights in a text table. The question apparently came from a perfectionist tableau designer. Tableau is not really made for text processing. But for someone visually sensitive, he or we may wish to design a text table beautifully.

Here is what it is about. 

Problem Statement

We assumed that the text has been properly line-broked to accommodate a certain width.

In Tableau we usually have a text table like this:

Note that, when the row heights are equal, it leaves a lot of white spaces. What we want is actually like this:

The row height is variable, removing unnecessary blank spaces.

The Tableau Solution

Jonathan got a solution using Python to preprocess the data. I tried using Tableau only and found a solution that doesn't need extra tools. 

1) First, we can calculate the number of new rows per each Row ID, by counting the number of line breaks. (per Jonathan's courtesy)

2) Secondly, let's perform the self-union of the data source. Note that the data source is in the 'breaks' sheet of an Excel file. In the Tableau data source editor, drag the break sheet to the editor canvas first. Then drag it again to the lower side of the first sheet, an orange rectangle of Drag table to union will appear. Drop the sheet there and we will have a self-unioned data source.
3) After self union of the data source, we rename the data source as "Text table with linebreaks SU". Now we create a new field "Row Index" as follows.
This will help create Index of rows per Row Id, that is, the index for the new rows as inserting line breaks. 

4) Right click "Row Index" and create bins named as "Row Index (bin)"
Using this field "Row Index (bin)", we create a new table with indexes within each Row Id. In the Text String field, the string is the same one per Row Id with multiple line breaks. Note that there are three dots "..." at the end of each string.
5) For technical reasons, we can't use "Row Index (bin)" in our calculations, neither with Index() function based on the bins. (For the curious ones, Tableau's string functions don't accept aggregated fields)

So, to keep the indexes which are absolutely necessary, let's export the data to a .csv file to create a new data source. The new one has a new index field. Note that we are using Tableau to do some data processing and reshaping.

Go to the menu Analysis>View Data which will open the view below. Download the table into a new .csv file. And our data preparation is finally done.
6) Import the new .csv file into Tableau. Rename "Row Index (bin)" as "Row Index". Create a new field "Text Row" as follows.
This formula will extract each of the new rows by line breaks per Row Id. See the table below.
By hiding the Row Index column, we obtain the table with variable row height. We leave it unhide for your understanding.

Voila we just turned a table of equal row height into one of variable row height in Tableau.

Download the above workbook here.

This is one approach to handle text wrapping in a text field. I have written another post before. Tableau doesn't do it well. That's why we have to go through some acrobatics to achieve it.  



0

Add a comment

Creating In-Place Help Page for Tableau Dashboards
Accommodating Variable Height in a Text Table in Tableau
A 30-Day Learning Plan for Mastering Tableau
A 30-Day Learning Plan for Mastering Tableau
Embedding Mundane Charts with Pareto Insights
Creating Pareto Chart Multiples in Tableau
A Preview of Sankey Chart Type in Tableau 2024
AI's Perception of People Looks in USA
1
AI's Perception of Top US Banks as a Dog
Multi-Level Sankey with the New Sankey Chart Type in Tableau
A First Look into the New Sankey Chart Type in Tableau
Visualizing Cross-Tab Tables with Column Sort
1
A Couple of Mismatches in Tableau's Map
Converting Date to Fiscal Calendar Date in Excel
Converting Date to Fiscal Calendar Date in Tableau
Resolving Simpson's Paradox: The Whole vs The Parts
#TweakThursday: Horizontal vs Vertical Bars
Recreating Datasaurus Dozen in Tableau
Rendering Anscombe's Quartet in Tableau
How to install database drivers for Tableau in Mac
Drawing Line Charts without Axis Offset in Tableau
Charting "Top N and Others" via Table Calculations in Tableau
Calculating YoY of Quarterly and Yearly Sums in Tableau
Imagining Tableau Social
Imagining Tableau Social
Imagining an Enhanced Formula Editor for Tableau
Imagining an Enhanced Formula Editor for Tableau
Filtering Partial Date Period in Tableau
How to Send Email from Tableau with a Template
How to Make Phone Calls from Tableau via Cisco Jabber
Labeling Trellis Chart via Stacked/Shared Axis
Sizing a Trellis Chart in Tableau
Placing Multiple Labels in Trellis Chart
Creating Compact View of a Sparse Table in Tableau
Labeling Trellis Chart Anywhere in Tableau
3
Labeling Trellis Chart in Tableau
1
Computing Spearman's Rank Correlation in Tableau
Computing Cumulative Grand Total in Tableau
Filling Down in Tableau
Pre-Filters, Post-Filters and the Order of Operations in SQL
2
Charting Project Flow via Multiple Data Densifications
Calculating Period-To-Date/PoP with Indicators for Better Performance
Counting Consecutive Occurrences in Tableau
1
Creating Bridge Chart with ARR vs AOP
Calculating the Difference Between Any Two Points in Tableau
Drilling Down with Containers
Creating Sunburst Chart via Map Layers in Tableau
Simple Calculations for YTD/YoY, QTD/QoQ, MTD/MoM and WTD/WoW in Tableau
9
One Button Sheet Swap in Tableau
One Button Sheet Swap in Tableau
2
Coloring the Area between Two Lines in Tableau
Sorting 100% Stacked Bars by Percentage
Creating Kanban Board in Tableau
4
Multiple Bars and Lines in Layers
Referencing Another Data Source without Relationship in Tableau
2
Dynamic Date Granularity and Show Missing Grains
4
Creating Global Variables in Tableau
Creating Sankey Funnel Chart via Template
59
Creating a Simple Toggle Button in Tableau
Monitoring Data Source Delay in Business Dashboard
Analysis of Tableau's Multi-Variable Clustering Algorithm
Iris Classification via Clustering in Tableau
Always Showing Empty Columns in Tableau
Creating Date Range Filter with Dynamic End Date = Max Date
5
Visualizing Crosstab and Grand Totals
Getting the Last Date/Value/Variance in Tableau
A Template for 3-Stage Sankey Chart in Tableau
26
Deselecting Button on a Different Sheet
Deselecting/De-dimming Buttons in Action-Driven Sheet Swap
3
Game of Life in Tableau
Enhancing Text Tables with Visual Background
1
20 Calculation Use Cases: LOD vs Non-LOD
Nested Sorting and Hierarchical Nested Sorting in Tableau
1
Creating 3D Bar Chart via Custom Shapes
Creating Sankey Chart with Sorting/Grouping
5
Creating Sankey Chart with Grouping
4
Enhancing Chart Contrast #TweakThursday 43
Creating a Multi-Stage Sankey Chart via Template Cascading
13
Creating Radial Stacked Bar Chart in Tableau
11
Creating Waffle Chart Multiples in Tableau
Creating Waffle Chart from a Single Percentage in Tableau
Creating Hierarchical Bar Chart in Tableau
Hiding Subtotals at Single Subcategory in Tableau
3
Making Label Text Wrap in Tableau
9
Accessing Excel Files on SharePoint from Tableau
Accessing Excel Files on SharePoint from Tableau
Creating Bar Chart Multiples In One Sheet 2/2: Different Measures
Creating Bar Chart Multiples In One Sheet 1/2: Same Measure
Using Color to Reveal More Insights #TweakThursday 42
Customizing Subtotals and Grand Totals in Tableau
4
Annotating Dual Axis with Alternative Color Legend #TweakThursday 41
A Divide-n-Conquer Approach to Counting Word Occurrence
Sorting Stacked Bars in Tableau
8
256 Cellular Automata in One Sheet
Creating Polygon Hex Maps in Tableau
Creating Joy Plot in Tableau With Fewer Steps
How Amazon failed to deliver: Analytical lessons
Polygon-based US Hex Map Revisited
Visualization, Data and Tableau Eco System
Creating Sankey Chart as Easy as 1-2-3 in Tableau
62
Tableau Licensing Cost Visual Calculator
Tableau Licensing Cost Visual Calculator
Creating 3-Way Venn Diagram with Dynamic Labels
1
Placing and Aligning Labels on Small Multiples
1
#WorkoutWednesday 35 - Superstore Small Multiples Tiled Map with Quad Chart
Creating Polygon Circumscribing Graph #MathVizMonday
Blog Archive
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.