So… you want to write fast calculations in Tableau Desktop? Me too.

Our blog will help you;

  1. make your dashboards faster
  2. easier to support
  3. and not too challenging for the next data guru

If this is too easy, please check out our analytics automation training at Knime.dev!

Writing Tableau Desktop calculations correctly, may feel like a bit of a foreign language …

Writing Tableau Desktop calculations correctly, may feel like a bit of a foreign languag for most people, however once you get rid of the old habits and learn the correct way to write calculations, your ability to solve quickly and optimally will increase.

Use our functions dashboard – to help kick start your journey learning all the functions used in Tableau. And once you master memorizing the functions, how the heck are you gonna write those efficiently?!

Well don’t worry, you don’t need to memorize the functions, that’s why we built the dashboard.

Truth be told, there’s not a lot of trainers teaching classes how to write code efficiently, they are instead focusing on teaching people how to solve problems because that’s the entire reason for using Tableau software!

Below is a quick tutorial – originally published on tableau.com community forums but I’m reposting the basics on Dev3lop.com! But feel free to check out the full tutorial here: fast tableau calculations.

Consider how MUCH analytics content is awesome, VS bad. Be sure to share this with your Tableau developer.

Slowest Tableau Calculations to Fastest Tableau Calculations for given use case.

SLOWEST CHOICE:

if month(date)>=5 then “orange”

elseif month(date)<=4 then “blue”

else “filter out”

end

// you don’t need to tell an extract to keep track of a lot of strings because it makes everything slower, it makes the extract bigger, and it isn’t going to help complex workbooks or large data sets. it will actually hurt the workbook if they want to ‘FIND these colors’ for later aggregation, which is generally always the case as they advance in their skills. also, this generates a lot of STRING manipulation in aggregation at a later date. Which generates super slow workbooks for no reason.

SLOW CHOICE:

if month(date)>=5 then “blue”

else “orange”

end

// else isn’t necessary and 2 strings is slow.

SLOW-ish CHOICE:

if month(date)>=5 then “blue”

end

// else converts to NULL vs asking the app to write ORANGE.

A LITTLE FASTER: (using comments to explain what things need to be)

if month(date)>=5 then 1 //blue

elseif month(date)<=4 then 2 //orange

else 0 //filter out

end

// this is a step in the right direction, requires a lot less pain in the future because you’re teaching them to use INTEGERS which databases prefer over STRINGS because there’s only 0,1,2,3,4,5,6,7,8,9 choices, where strings have HUNDREDS of choices, and you’re asking the database to effectively work more than necessary and complicating the calculations.

A FASTER CALC:

if month(date)>=5 then 1 //blue

else 0 //orange

end

// just typing numbers, and commenting out strings would make this scalable for complex workbooks and bigger dataz.

Pretty dang fast.

month(date)>=5

// boolean flag.

Write fast calculations in Tableau Desktop and grow the community!

Writing fast calculations in Tableau Desktop is important for user adoption. Also, it will help grow the community to become great at native tableau desktop features. Eventually calculations need to be optimized – and this can be very complex in the future if there are hundreds of slow calculations.

Hope this helps all the new peeps in the forums.

Please start with — https://www.tableau.com/learn/training

Best,

Tyler