**You can take notes as you view lessons.**

Sign in or start a free trial to avail of this feature.

Certain calculations can create performance delays in large datasets. This lesson provides some quick tips for optimizing calculations for speed.

**Hierarchy of data types - fastest to slowest**

**1** Number or Boolean (TRUE / FALSE)

**2** Date

**3** String

**Tips for improving the performance of calculations**

- Ensure IF / ELSE statements return a TRUE/FALSE option or numbers (e.g. 1, 2, 3)

- Convert dates to integers if DATEDIFF() or DATEADD() are causing delays

- Avoid using parameters on row-level calculations

- Move table calculations (e.g. running sum) to the data source

When considering how much risk, calculations present to your visualization's performance, we must first consider the data type of the fields used in your calculations. Tableau treats data types differently when it comes to performance. Numbers and booleans have the fastest performance, followed by dates and finally text strings. When you have smaller data sets, it's okay to ignore this hierarchy. Because even when using strings, you probably won't see much performance degradation. However with larger data sets, you may want to consider this hierarchy very carefully. In certain situations, you may want to convert a date or a string, into a number or a boolean format, to improve the performance of your visualization. Let's make this a little more tangible, by taking some concrete examples of when to do this.

We'll start with the if, then statement, often resulting in a string. If you need to improve the performance of this statement, then you can replace it with one that results in a boolean. So for example, if we have two colors that currently return red or blue, flip this to a true or false.

If it turns out that your if, then statement has three total results, consider changing the results to numbers rather than strings. Such as exceeded, met and did not exceed. Again, this is not entirely ideal from a user's perspective, but it can improve performance when it needs to.

Next we take a look at dates, and more specifically, the distance between dates. If you have a date diff, or a date add function that's affecting your performance, you can convert the dates to integers, which will enable a simple addition or subtraction. Which is faster than date diff or date add.

In the following calculated field, I have a date diff function, that finds the difference between today's date and the last date a payment was received from a customer. To speed up this calculation, I can convert both dates to integers, and then subtract one from the other. I'll use the int function, to first convert the today function, and then the int function again, to convert the max payment date.

When I click okay, you can see the chart stays the same, as the calculation is the equivalent of my previous date diff function, just a lot faster.

Another way of improving performance, is to avoid roe level calculations involving perimeters.

In many cases, these calculations can happen in the data source. Be it a CSV, Excel file, or in a data base. The same goes for table calculations. If you want to calculate the percentage of total, or a running sum, these calculations are very convenient in Tableau, but they can be slow on larger data sets because they happen in the local computation engine. To improve the performance of table calculations, try to make these calculations in the data source. Be it a server or a file, and in general, this will greatly improve the performance of your visualizations.

Advancing in Tableau

Optimizing for Performance

Sign in or start a free trial to avail of this feature.

Sign in or start a free trial to avail of this feature.