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$]
Select 1 as [data_x], 400 as [data_y] from [Sheet1$]
Select 400 as [data_x], 1 as [data_y] from [Sheet1$]
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.
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.
I played around with different versions of this with some cool results…
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.
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.
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.