Tableau Consultant Grinding Automation with Macros

Tyler
7 min readDec 8, 2017

--

This is a very very fun topic. — — Update: We use Keyboard Maestro now, it’s much more user-friendly — this here looks scary. We’ve grown up a little to understand that user-friendly wins and AHK is cool when you need it. Keyboard Maestro would be a much better solution — Updated 7/7/2017 by Tyler Garrett

Corey, this is absolutely great. I do have a question, I’m interested to know why you replaced alt+a+c with another 3 button combination? I’ve done this on other apps because it felt more natural, habit from Counter Strike days maybe?

Just landed in a similar boat, will be releasing all the source code of an “arcade style” for common steps generated.

Below I’d like to share similar to what you’re doing. I was thinking along the lines of ONE CLICK WIN button. I love it.. maybe it could be a different super relevant scenario.

Need to generate a few hundred calcs, high risk of error with tools available, and been thinking, might as well just script all of it. I like the direction you’re going, one big mention — — I see the intro controls can often JAM UP the logic later in the script, here’s a little knowledge transfer for those passing through. How did you handle the initial release of the “new” keys, and then your app releases all the fresh code? I ended up getting around it with being logical about the literal button and also “hopefully it works” a catch to WAIT if the end user hasn’t released the original buttons…

I’m using Sendmode Input, as it can be more reliable for key strokes. “for sure” clean way to make sure everything fires off. Below quote explains keystroke delay time global set, which is pretty great once you realize all the limitations with the default send mods.

sauce

“SendEvent [v1.0.43+]: SendEvent sends keystrokes using the same method as the pre-1.0.43 Send command. The rate at which keystrokes are sent is determined by SetKeyDelay. By default, Send is synonymous SendEvent; but it can be made a synonym for SendInput or SendPlay via SendMode.”

;semi colon is COMMENT OUT, double dash — is a comment out in stand sql syntax, so in notepad ++ this looks great because it will catch comments as sql comments, YW!

; — …Some code that generates a calc, titles it, and tabs down to paste a calculation , z1 & z2

; — …your header

z1 = your calc logic, you dont need anything crazy around this, it will simply zap it in there. send event does this “INSTANTLY”, other mods TYPE IT OUT, extremely slowly…

z2 = your calculation title

Sendmode Event ; — …after many hours and hours of debugging, sendmode event stole the show and just KEPT working.

SetKeyDelay, 300,500 ; — …long story short with sendmode event, it plays well with Tableaus software/computer delay, and as you begin making these scripts, “Sleep, 1000” all over the place to get the timing of keys down is just not good.

; — …your input macro

BlockInput On ; — a means of keeping end user from being able to click off, type things, etc… send event (if i recall correctly) allows for good send controls because it holds all incoming traffic until the portion is complete (aka Return)

Send {LAlt down} ; — left alt

Send {a down}

Send {a up}

Send {c down}

Send {c up}

Send {LAlt up}

Send, %z2%

Send {Tab down}

Send {Tab up}

Send, %z1%

BlockInput Off

Return

!F7::KeyHistory ; — I’d recommend always having a at the end, this can help explain what’s going on in the back end. I like alt+f7, you can increase the amount captured by your script if you “#KeyHistory #” in your header — No double quotes.

For those getting into it first time::: I recommending using the “AutoHotkey Help” and start from the beginner tutorial. If you’re really good at calcs in Tableau, or getting good at it, it can be right up your alley, if you just focus on the core concepts before jumping super deep. If you’ve been programming, it’s very straight forward, and if you just hack around in code — it’s a very fruitful adventure and you will find this easy.

Tips::

  1. capital letters matter most of the time, except when using %variables% — lots of little corks in the notes, as you begin to debug.
  2. lots of the code will run, even though it doesnt work at all.
  3. if it’s not working correctly, do everything you can to simplify it first.
  4. maybe you want to do 5, or 6 hotkey macros/mouse movements, but a few don’t work, avoid doing it all at once, it becomes impossible to debug, keep it extremely simple, then add the complexity.
  5. go find a community posted source code, read it, copy and paste code.

This gif shows the below screen shot of code in usage. The gif doesnt show me press 1, but it is being pressed, gifcam isn’t perfect.

Because this application can be absolutely toxic to your end user experience on your computer (joking, but seriously be careful what you download and use, not to scare you, just a warning), I recommend you don’t have any production reports open, nothing you care to lose, or BOSS instant msg convo you care to accidentally send a calculation or dive into some menu on a random application you didn’t mean to do… Because of that, I will just paste my current beta version, keeping the copy pastes very much “you’re accountable”

Cheers Fam!

Tyler Garrett
https://dev3lop.com

We offer advanced content on the Tableau Community too.

Like; How to write Fast Calculations in Tableau Desktop, How to count wins in Tableau desktop.

We offer fun community challenges. Solutions to many to many using basic SQL.

Some call it a solution to dynamic parameters — which is the most requested product feature!

Also, we spend a good deal of time offering product feedback. We really know the product and love helping the community forum with all kinds of challenging usecases. https://community.tableau.com/ideas/1328

--

--

Tyler

blogging helps me learn, remember, and understand concepts. www.dev3lop.com. www.tylergarrett.com, twitter = @itylergarrett