## Drawing Letters in Tableau

La versión en español está aquí

Little step-by-little step, making progress in my quest to understand what Tableau can offer beyond “Show me”. Inspired by Ken Flerlage‘s series of “the X & the Y“―but not quite yet at the level of parametric equations―  I’m designing here a tool to use Tableau’s canvas as a blank slate to draw some letters (say goodbye to 72pt size limit!).

Aim:

• Being able to enter a text (or, rather a 9-or-less-letter word) and draw it letter by letter using a combination of calculated fields in Tableau.
Steps:
1. Get the equations to draw the different letters in a given position ―template using Excel.
2. Transport the equations to all the different possible positions using Alteryx.
3. Create a workbook in Tableau to use as a template.
4. Generate all the different calculations and place them in the worksheet computing as needed in the workbook using Alteryx.

## Getting the Equations to Draw Some Letters

1. Get the equations to draw the different letters in a given position ―template using Excel.
1. Obtain a set of equations.
2. Break it down into the individual segments compatible with Tableau.
3. Rewrite the equations as needed.
Some of the equations in the page are not compatible with the way Tableau draws its marks: You just cannot feed the equation needed to draw the letter “C” to Tableau. The original equation: $\left(x-1\right)^2+\left(y-1\right)^2=1\left\{x\le1.75\right\}$ can be split in two segments for y: $y = 1+\sqrt{1 – \left(x-1\right)^2} \left\{x\le1.75\right\}$$y = 1-\sqrt{1 – \left(x-1\right)^2} \left\{x\le1.75\right\}$ that “1.75” is a placeholder for a given position of X -but will need to be updated for other positions.
En Excel (y con la ayuda de papel y lápiz para despejar la x y la y), con un poco de paciencia, reconvirtiendo todas las ecuaciones en función de la posición de x: Muestra de las ecuaciones de los distintos trazos — click para descargar todas.
1.2 Some of the equations in the page are not compatible with the way Tableau draws its marks: You just cannot feed the equation needed to draw the letter “C” to Tableau. The original equation: $\left(x-1\right)^2+\left(y-1\right)^2=1\left\{x\le1.75\right\}$ can be split in two segments for y: $y = 1+\sqrt{1 – \left(x-1\right)^2} \left\{x\le1.75\right\}$$y = 1-\sqrt{1 – \left(x-1\right)^2} \left\{x\le1.75\right\}$ that “1.75” is a placeholder for a given position of X -but will need to be updated for other positions.
1.3 In Excel (with the help of pen and paper to isolate x and y), and with a little bit of patience, reshaping the equations to draw based on x: Sample of the different strokes –click to download all.

## First Incursion into Alteryx - getting things ready.

1. Transport the equations to all the different possible positions using Alteryx.
1. Decide the number of letters that we’re going to use.
2. Convert the Excel template with the formulas to draw letters into proper Tableau Calculated Fields.
3. Repeat the process with the different positions defined in (1)  (45 calcs right around the corner straight from here).
Restrict the number of letters to 9, with these characteristics (start & end defined as a function of the original equations, with a max-width per letter of 2 units and the position of the letter in the Tableau canvas). Letter positioning.
Using Alteryx and the template obtained in (1.3) to automate the process. Process the template to obtain the formulas for Tableau. Doing this, for each letter we obtain a set of five formulas (one for each segment–some letters can be drawn using a single stroke i.e. “i”, while some other need up to 5 i.e. “b”). Output of running the Alteryx workflow in the original template.
Combining the total number of letters with start & end (2.1) and the Alteryx workflow to obtain the text of the 45 formulas (2.2): Let’s combine the possible positions with the stroke template. And the output: Output with the 45 calculations — click to download the Excel file.
2.1 Restrict the number of letters to 9, with these characteristics (start & end defined as a function of the original equations, with a max-width per letter of 2 units and the position of the letter in the Tableau canvas). Letter positioning.
2.2 Using Alteryx and the template obtained in (1.3) to automate the process. Process the template to obtain the formulas for Tableau. Doing this, for each letter we obtain a set of five formulas (one for each segment–some letters can be drawn using a single stroke i.e. “i”, while some other need up to 5 i.e. “b”). Output of running the Alteryx workflow in the original template.
2.3 Combining the total number of letters with start & end (2.1) and the Alteryx workflow to obtain the text of the 45 formulas (2.2): Let’s combine the possible positions with the stroke template. And the output: Output with the 45 calculations — click to download the Excel file.

## Tableau Template

1. Create a workbook in Tableau to use as a template.
1. Design the datasource.
2. Outline of the view to draw the letters: calculated fields and how to compute them using the bins from (1).
3. Calculate the different letters (which letters? what position?).
In a new worksheet:
1. The bins created earlier (padded) in detail to provide the context to compute the different table calculations.
2. The calculated field “t” is going to be the “x-axis”. Adjusted with hardcoded values of 100 y 200 based on padded.
1. With “t” and “padded” ready, the only thing left is to bring into the view the calculated fields for the segments of all the letters. I’m using only a couple as an example, where I copy the text generated earlier. All the calculated fields will be created in Alteryx using this as a template.
2. Each segment needs to be computed using padded –for t and for letter.
To calculate the letters (which letters and where) we can combine some calculated fields:
1. The first one, that I called “Name_letters“, is based on a parameter (in this example; however, it could vary based on other measures, say the sum of sales as seen here —example). Obtaining the text to draw based on a parameter. Could be replaced with a calculated field based on other measures as seen here.
2. Next, one calculated field per letter. Given that the different intermediate points do not exist in the datasource (rather, they’re generated with the bins) it is necessary to use table calculations to retrieve them: Obtaining the first letter–table calculations are needed here. Changing the “start position” of the table calculation we can obtain the different letters.
3. Finally, a calculated field based on the x-axis to decide which letter goes where. Deciding which letter to draw where based on the position in the x-axis. Hardcoded.
3.2 In a new worksheet:
1. The bins created earlier (padded) in detail to provide the context to compute the different table calculations.
2. The calculated field “t” is going to be the “x-axis”. Adjusted with hardcoded values of 100 y 200 based on padded.
1. With “t” and “padded” ready, the only thing left is to bring into the view the calculated fields for the segments of all the letters. I’m using only a couple as an example, where I copy the text generated earlier. All the calculated fields will be created in Alteryx using this as a template.
2. Each segment needs to be computed using padded –for t and for letter.
3.3 To calculate the letters (which letters and where) we can combine some calculated fields:
1. The first one, that I called “Name_letters“, is based on a parameter (in this example; however, it could vary based on other measures, say the sum of sales as seen here —example). Obtaining the text to draw based on a parameter. Could be replaced with a calculated field based on other measures as seen here.
2. Next, one calculated field per letter. Given that the different intermediate points do not exist in the datasource (rather, they’re generated with the bins) it is necessary to use table calculations to retrieve them: Obtaining the first letter–table calculations are needed here. Changing the “start position” of the table calculation we can obtain the different letters.
3. Finally, a calculated field based on the x-axis to decide which letter goes where. Deciding which letter to draw where based on the position in the x-axis. Hardcoded.

## Second Incursion into Alteryx and Last Touch Ups in Tableau

1. Generate all the different calculations and place them in the worksheet computing as needed in the workbook using Alteryx.
1. Understanding the differences between the calculations previously obtained in Alteryx and the structure that calculated fields have in Tableau.
2. Transform text into HTML and creating the formulas following Tableau’s format.
3. Update the worksheet to use the calculated fields making sure they are computed correctly using padded.
4. Alteryx workflow detailing the steps outlined in 4.3.
Let’s have a look at the XML in the workbook again. This time, just focus on the structure of the worksheet: Tableau’s worksheet. There are three sections were calculated fields will need to be added: Worksheet structure as seen in the XML.
1. It seems clear that, given that we are using “Measure Names”, to be able to add additional calculated fields we have to edit the “categorical filter”. We’ll need to add as many “Groupfilter” sections as calculated fields.
2. Rows will have the measure values and “t” in columns.
3. To compute the full-range of padded we’ll need to show empty rows from the table layout option.
BUT… THIS. IS. NOT. ALL. Having a look at “Datasource dependencies” we’ll find out that two entries are needed for each of the calculated fields that we want to add to the view.
1. The first one is just the same one used earlier with the field name, alias, type, etc. Calculated field definition, the same as the one used earlier.
2. The second one, “column-instance“, contains the specific information needed for this particular view, including how to compute it. This view’s specific information — detailing how to compute it.
4.3 Let’s have a look at the XML in the workbook again. This time, just focus on the structure of the worksheet: Tableau’s worksheet. There are three sections were calculated fields will need to be added: Worksheet structure as seen in the XML.
1. It seems clear that, given that we are using “Measure Names”, to be able to add additional calculated fields we have to edit the “categorical filter”. We’ll need to add as many “Groupfilter” sections as calculated fields.
2. Rows will have the measure values and “t” in columns.
3. To compute the full-range of padded we’ll need to show empty rows from the table layout option.
BUT… THIS. IS. NOT. ALL. Having a look at “Datasource dependencies” we’ll find out that two entries are needed for each of the calculated fields that we want to add to the view.
1. The first one is just the same one used earlier with the field name, alias, type, etc. Calculated field definition, the same as the one used earlier.
2. The second one, “column-instance“, contains the specific information needed for this particular view, including how to compute it. This view’s specific information — detailing how to compute it.