Skip to main content

How to Start/Stop your Script in Python

Sometimes when we’re running a script, we want to be able to break down and review portions of our code. In Alteryx, we can easily do that with the cached results function in every tool or we can use the Browse tool.

In Python, we can use this little trick with the “raw_input()” function.

Say for instance we want to run 2 pieces of code

  1. Give me a list of odd numbers
  2. Give me a list of even numbers

But I want to be able to check over my work in the first section before running the 2nd. This is really useful if your data is EXTREMELY large and takes a long time to run. To avoid the pain of spending 20 minutes waiting for your script to finish running, only to find bugs early in the process, checking your results throughout (in conjunction with a filter!) will hopefully save you from lots of hassle.

Here’s the script:

# How to start and stop your code

# Step 1: Prints some odd numbers

for x in xrange(1, 20, 2):
print x

# Step 2: Pop up messsage that stops the script from running the next function until "enter"

raw_input("Press <enter> to continue")

# Step 3: Code continues on and prints some even numbers
for x in xrange(2, 20, 2):
print x

Here’s the video on how I did this:



How Do I Prepare for #data16?

So you’ve taken the plunge and are going to the Tableau Conference. Everyone talks about how amazing it is and how many people you’ll meet… so how do we make sure you’re going to have an awesome time in Austin?

I’ve already gone into the future and video recorded how I’ll be on the plane.


I’m asking Jonathan Drummey, Paul Chapman and Carl Allchin on the Tableau Wannabe Podcast how I can make this happen.

A couple questions come to mind:

Who are the best speakers to watch? 
Lots of people have told me that this is one of the best ways to pick sessions. Who’s on your list?

What events are “can’t miss”? Which ones are “meh”?
We only have a couple days! Don’t want to be left out of a session that everyone is buzzing about!

All the Tableau sessions are recorded? Any value in going to them anyways?
Realistically, do you actually go back to watch them?

According to Paul Chapman, we should do test runs of our conference plans?
Overkill or necessary?

How organized do you need to be about this conference?
Based on the blogs I’m reading, it seems I should have almost every minute planned!

What are some recommended sessions for Tableau Developers? Server Specialists? Biz Folk?

What’s the best swag you’ve ever gotten at the Tableau conference?
Which reminds me that I gotta get moving on my Spotify vi

Got questions?

Let me know by Oct 27, 2015 9PM BST and I’ll get it into our podcast!


How to Label Bin Ranges in Tableau

Histograms are great for helping us understand distributions of data, but Tableau currently doesn’t allow for the ability to label the upper and lower bounds of bins ranges.

Much thanks to Rob Suddaby for asking this question and to Robin Kennedy for his great answer.

Feel free to download the workbook from Tableau Public

Step 1: Create a Calculation

Here I’ve built in a parameter so I can adjust the size of the bins dynamically. If you only need it be a certain size, simply replace the purple fields with your bin size.

str(INT([Fare]/[Bin Size])*[Bin Size]) + ‘ – ‘ + str(INT([Fare]/[Bin Size])*[Bin Size]+[Bin Size])

The calculation works in 2 parts:

1) Calculating the upper and lower bound of the range.

2) Converting these values to strings and adding formatting with the “-”

Step 2: Build your view!

Thanks for reading!

How to Label Above Individual Bars

Wanted to share this technique on labeling dimensions above bars as an alternative to the default top align in Tableau.

Step 1: Create a Bar Chart

Step 2: Create a Dummy Continuous Variable

Tableau doesn’t allow you to align above the mark in a bar chart.. so we need to get creative and create a second mark that sits above the one we want to label, then hide traces of that mark.

To do this, I’ve created a continuous variable for Tableau to create a second axis (remember, these green pills will always draw an axis and create another mark).

0.01 is an arbitrary value but preferably one that is very small relative to the actual value you’ll be displaying. In my case, I have sales rendering in the thousands, so a value of 0.01 is sufficiently small.

Creating a dummy variable to draw a second axis and mark on the sheet. Creating a dummy variable to draw a second axis and mark on the sheet.

Step 3: Bring the new Continuous Variable to the View.

Dual axis and pills and synchronize the values.

Step 4: Bring Measure Names to Rows

Here’s the key to how it all works: “measure names” on rows. You’ll find this pill in the dimensions panel. This will separate the the “Dummy” measure and the “Sales” measure into 2 bars.

Then on the “Dummy” mark, bring the Dimension you would like to label onto text. You should get something like this.

The key to this is that we've plotted 2 measures together, but we're only using the dummy measure/mark as a way to label the below bar.   If you're finding the label is below the bar, simply switch the order of the green pills in columns. The key to this is that we’ve plotted 2 measures together, but we’re only using the dummy measure/mark as a way to label the below bar.   If you’re finding the label is below the bar, simply switch the order of the green pills in columns.

Step 5: Clean up your headers

Here I’m just hiding the headers we’ve created to structure the data in  the view and remove distractions.

That’s it! Hope this was helpful. Let me know if you have any questions.

Happy Vizzing!

How to Search for Short Lists in Tableau

Ever have a situation where you’ve got 10 or 20 individual items or order numbers you want to search for? It’s a pain to select each individual value (say for instance, we just want to look up a batch of OrderIDs).

How can we build something easy in Tableau to make this happen?

I built this dashboard so we can envision what this could look like. It’s got some top level metrics when nothing is entered, but will dynamically change to views on order ideas when they are copy and pasted into the search box!

And it’s easy to build in Tableau! Just a couple calculations and you’ll be on your way.

Step 1: Create a Parameter:

Make sure you’ve set it to string.

Step 2: Create the Calculation that Operates the Parameter

The action is a pretty simple match — we just have to adjust the inputs so that it will match what we’re putting into the parameter! Hence the addition of the commas on either side of the parameter and OrderIDs in the data.

Here’s the text for quick copy and paste:

if contains(“,” +[Parameters].[Selected Order IDs]+ “,” , “,” + [Order ID]+ “,”)== TRUE then  [Order ID] else NULL END

Then you can just put this pill onto your rows shelf, and it will act as a dynamic dimension.

Step 3: Configuring the Filter with your new Dynamic Dimension

This particular calculation will always give you some sort of NULL value.


Its because of the question we’ve built into the calculation. After all, we are asking Tableau to compare our manually entered parameter values against EACH OrderID in the data. Inevitably there will be a couple that don’t match! These will return the NULLs.

And Tableau is working exactly as we expect – all we have to do is “hide” these nulls.

I’ve chosen to do it with an “Exclude” on the filter with a Custom value list.

BONUS STEP: What do I do if the sheet goes blank?

You’ll notice that if no values are entered, your sheets will turn blank.

In my case, I’ve taken full advantage of that by overlaying sheets that will appear when no values are entered. This is just an extension of the oft-written about Show/Hide sheets functionality based on the number of characters in the parameter.

A pretty specific use case – but I think could have a lot of practical applications especially for call center teams!  Happy Vizzing!