# Painting with Tableau

## Introduction…

So, last week my router died… I was forcibly removed from the grid for 5 whole days with nothing but my mobile data plan to keep me connected… I considered it to be what nightmares are made of!

As I couldn’t download any datasets to play around with, I decided I’d attempt to sate my need to play around in Tableau by seeing what I could create without any data.

This post, rather than being a guide on how to attempt a specific end-result will be an overview of the steps I took to create a canvas in Tableau on which I could paint some pretty pictures using mathematical equations. EG…

You can find a Tableau workbook containing all of the work I did here. Feel free to download and dissect it.

## Create the Canvas…

The first step to being able to work in Tableau without data is to create some fake data.

I did this by simply connecting my new Tableau workbook to a completely empty Excel spreadsheet using a legacy connection.

Once connected I setup the following custom SQL query as my data source:

Select 1 as [data_x], 1 as [data_y] from [Sheet1\$]

union all

Select 1 as [data_x], 400 as [data_y] from [Sheet1\$]

union all

Select 400 as [data_x], 1 as [data_y] from [Sheet1\$]

union all

Select 400 as [data_x], 400 as [data_y] from [Sheet1\$]

The 400 is going to determine how many data points we have to work with in our canvas, 400 will allow us to have a 400 x 400 pixel canvas to play with. Increasing this number will give better definition in the images we’re going to create but it will also increase calculating time so try to find a balance you’re happy with.

Once you’ve done that you should have 2 fields available to play with in Tableau, data_x and data_y. Create bins on both of these fields with a bin size of 1 (I called mine bin_x and bin_y).

Now were going to create a few calculated fields.

index_x

index()-1

index_y

index()-1

index_max

(WINDOW_MAX([index_y]))/2

plot_x

([index_x]-[index_max])/[index_max]

plot_y

([index_y]-[index_max])/[index_max]

Now drag bin_x and bin_y on to the marks shelf, plot_x on to the columns shelf and finally plot_y on to the rows shelf.

Edit the nested calculated fields in plot_x and plot_y as follows:

index_x – Specific dimensions: bin_x

index_y – Specific dimensions: bin_y

index_max – Specific dimensions: bin_x, bin_y

Once you’ve done that you should be looking at something like this…

## Paint some pictures…

All that’s left to do now is to simplify some mathematical equations into something Tableau can understand and calculate them for x and y using your plot_x and plot_y fields.

I started simple with the following equation:

Which I simplified into my e_heart calculated field as follows:

[plot_x]^2 + ([plot_y][plot_x]^2^(1/3))^2

Note, I ignored the “= 1” portion of the equation, I did this simply because we’re not working with enough points (400 x 400) for the equation to calculate to zero decimal places. Instead I created a second calculated field as follows and dragged it on to colour.

[e_heart] < 1

Which gave me the following result.

And that’s pretty much it, I played around with several different equations which I just simplified into something Tableau could understand and added a few parameters so I could distort the images in different ways.

rings…

I played around with different versions of this with some cool results…

e_rings

abs(SIN([plot_x]^2 + [plot_y]^2)-COS([plot_x]*[plot_y]))

Note, I replaced the equals sign with a minus sign in my equations for the same reasons I removed the = 1 in the heart equation.

batman logo…

This one was slightly more complicated to simplify but if you’re interested I’ve uploaded a workbook to Tableau Public with all of my work in it. Feel free to download and reverse engineer it.

Several people in the Tableau community have done some awesome work around similar ideas, if you’re interested I’d really recommend giving some of the following articles a read.

Noah Salvaterra – The Rise of Tableau

Rody Zakovich – What can Tableau do with just 2 rows of data

Bora Beran – Going 3d with Tableau

Adam McCann – How to Game of Thrones Analysis Viz

Hope you all enjoyed the article, let me know in the comments below if you have any questions or problems. Also, let me know if you have any suggestions for future content/guides or anything you’d like me to take a look at.

Ryan.

## 8 thoughts on “Painting with Tableau”

1. Jay

Hi following the instructions, I just end up with 4 circles not matter what I try, never the matrix with 400×400 circles.

What am I missing? How do you “convert” the 4 records in the dataset into 400×400 points?

Liked by 1 person

• Did you create your bin fields and index fields? If so, the problem will be related to how your table calculations are being calculated.

Right-click your plot_x field and click “Edit Table Calculation”, from there you’ll see a drop-down box with names of other calculations in them, those are nest calculations – you need to set them to calculation as I’ve instructed above, along bin_x for index_x, bin_y for index_y and along both for index_max.

If you’re still having troubles, download my example workbook from Tableau Public and reverse engineer it.

Hope that helps.

Like

2. Jay

Thanks, I did exactly that. I built a new sheet which looks exactly the same in every way I can tell including the nested calculatations, yet I still have only 4 dots in the corners.

Liked by 1 person

• Could you upload a copy of your working file to Tableau Public and I’ll take a look to see if I can spot the problem.

Like

• Hi Joachim,

Not really sure what happened there, some weird behavior going on but I did manage to fix it.

To fix:
I dragged bin_x to the row shelf from the mark shelf
I right-clicked bin_x while it was on the row shelf and ticked “Show Missing Values”
I then dragged bin_x back to the detail shelf from the row shelf
I then repeated the same steps for bin_y

This shouldn’t be necessary as from what I understand when fields are on the detail shelf they should automatically “Show Missing Values” but you can workaround it as above.

Hope that helps,
Ryan.

Like

• Jay

Hi Ryan

Yes, that solved the issue, The grid is now appearing. I’m still not sure though how the (nested) calculations generated 400×400 data points out of the four initial records and how the “missing values” can actually have “data” which makes them appear on a grid though… worth some more investigation.

Liked by 1 person