Random Numbers in Tableau

Random Numbers in Tableau
Photo by Edge2Edge Media / Unsplash

Having a lot of uniform data you might want to introduce some jitter to the data visualization.

Most of the tutorials would suggest to use a random number and apply it to an axis to offset the visualistion point a bit. So far so good.

Tableau for special had a hidden function called RANDOM() for quite some while which got removed recently. Their forums are full of requests to bring it back without much response from what I see.

On my search for a workaround I found following solution for Snowflake (should work for every DB, though):

// The easiest way

// Uniform the random number to be between 0 and 1
RAWSQL_REAL("uniform(0::float, 1::float, random(42)")
Calculated Field: Jitter

The idea is quite straight forward: I'm simply using the random() function of my datasource. In case of Snowflake I suggest to use a seeded random function what will prevent "jumping" datapoints after each reload (In my case it's seed "42").

In case you need a constrained random number, simply use the Snowflake uniform() function to map the random numbers to your needs.

This works for non-extracted Data-Sources. For everything else, I'll post a Pseudo-Random-Number-Generator code shortly. Interested? Subscribe to my Blog or drop me a line on Twitter.