Trend lines in Tableau

What is the Trend Line in Tableau?

Trend lines in Tableau enable you to highlight any trends in the dataset that are used to create Tableau visualization. Trend lines can be added to the majority of visualizations in Tableau, and these are supported across various Tableau ecosystems such as Tableau Cloud, Tableau Desktop, Tableau Public, and Tableau Server. Tableau supports a variety of customizations to the trend lines that you can use in your visualization. Using these trend lines, you can forecast future predictions based on current data points.

A sample trend line in Tableau visualization looks like the one provided below.

Trend line in Tableau - Sample
Key Takeaways
  • Trend lines in Tableau help you to highlight any trends in the dataset in your Tableau visualization. 
  • Tableau supports a variety of customization to the trend lines that you can perform on your visualization.
  • Using these trend lines, you can forecast future predictions based on current data points.
  • Tableau supports 5 different types of trend line models for adding trend lines to your visualization.
  • You can add, edit, or remove a trend line to your visualization.
  • Be aware of the limitations associated with trend lines before you consider them adding to your visualization.

Types

Tableau supports five different types of trend lines. These include:

#1 – Linear Model

  • A linear model type follows the linear trend line with a formula

Y = b0+b1*x, where b0 refers to the intercept of the line and b1 is the slope

  • A typical linear model trend line looks like the one below
Trend line in Tableau - Linear Model

#2 – Logarithmic Model

  • A logarithmic model type looks like the one below
Trend line in Tableau - Logarithmic Model
  • It is based on the below formula.

Y = b0 + b1 * ln(X)

It uses a logarithmic function that doesn’t work for cases where the variable is negative or 0. Hence, any such values in the explanatory variables are filtered out before this model can evaluate them. It is helpful to understand how many data points were eliminated before model estimation using this trend line model type.

#3 – Exponential Model

  • The exponential model type uses a natural log function to estimate the trend line in your visualization
  • The formula for this model is

Y = exp(b0)* exp(b1 * X)

You can also represent the model with the below formula

ln(Y) = b0 + b1 * X

By applying the natural log function on both sides of the formula, the final formula becomes

Y = b2*exp(b1 * X)

  • A typical exponential model trend line type looks like the one provided below
Trend line in Tableau - Exponential Model

#4 – Power Model

  • The power model type is based on the formula specified below

Y = b0 * X^b1

When you apply natural log on both sides of the above formula

ln(Y) = ln(b0) + b1 * ln(X)

It is used to plot a trend line in the visualization

  • A power model trend line looks as below
Trend line in Tableau - Power Model

#5 – Polynomial Model

  • In a polynomial model type, the independent variable is transformed using a polynomial series as per the below formula

Y = b0 + b1 * X + b2 * X^2 + …

One must specify a degree of order while using a polynomial model trend line.

  • A polynomial model trend line appears as shown below.
Trend line in Tableau - Polynomial Model

How to add a Trend Line in Tableau?

To add a trend line in Tableau, you may follow the instructions below

Step 1: Create a data visualization using Tableau Desktop or Public. Alternatively, you can open an existing visualization in Tableau.

Step 2: Navigate to the Analytics pane.

Trendline in Tableau - Add - Step 2

Step 3: Under the Analytics pane, drag the Trend Line visible under the Model section to the Tableau view and then drop it into one of the trend line model types, i.e., Linear, Logarithmic, Exponential, Polynomial, or Power.

Trend line in Tableau - Add - Step 3

Once you drop the Trend Line on a model type, Tableau will add a trend line to the visualization, as in the visualization below.

Trend line in Tableau - Add - Step 3 - visual

Note: You can also add multiple trend lines in Tableau following the similar steps highlighted above.

How to edit the Trend Line in Tableau?

The trend lines added to an existing visualization in Tableau can be edited to support data analysis.

To edit a trend line in Tableau, you may follow the instructions below

Step 1: Open your existing visualization using Tableau Desktop or Tableau Public. Go to Step 2.

Step 2: Right-click on the existing trend line in the Tableau view. View the context menu.

Step 3: In the context menu, select Edit All Trend Lines option

Trendline in Tableau - Edit - Step 3

Alternatively, you can also choose from Analysis – Trend Lines – Edit All Trend Lines…

Trendline in Tableau - Edit - Step 3 - Analysis

Step 4: In the Trend Lines options, configure the options as available on the screen.

  • Model Type – Choose one of the Model Type options, i.e., Linear, Logarithmic, Exponential, Power, or Polynomial. For Polynomials, provide the degree option between 2 and 8.
  • Factors – Select which fields to use a factor in the trend line model. 
  • Options – Specify whether to show tooltips on the visual.
  • Select whether to Show confidence bands. By using this option, you can add confidence bands to your view. By default, Tableau displays upper and lower bands by 95% confidence intervals.
  • Specify whether you want to allow color trend lines in Tableau. This option excludes color encoding and enables you to add a single trend line modeling all data types. 
  • Show recalculated line for highlighted or selected data points option allows you to select or highlight data points in your visualization.
  • The Force y-intercept to zero option is useful, especially when you want to start the trend line at 0. This option is enabled only when both the columns and rows shelf contains a continuous field, and the visualization is a scatterplot.
Trendline in Tableau - Edit - Step 4

How to remove the Trend Line in Tableau? 

To remove the trend line in Tableau, follow the steps below:

Step 1: Drag the existing trend line off the visualization area. Alternatively, you can choose a trend line and select the Remove option.

If you want to remove all the trend lines in a data visualization view, choose Analysis -Trend Lines – Show Trend Lines. Untick the Show Trend Lines in Tableau to remove the trend line.

Trendline in Tableau - Remove - Step 1

Now, let’s look at some of the examples to understand the trend lines better.

Examples

In this section, we will examine some of the different scenarios in which we can apply trend lines to data visualization in Tableau.

Example #1

In this example, we will create a line chart visualization in Tableau and then add a trend line to the chart using the NASDAQ Composite Time Series dataset. The NASDAQ Composite Time Series dataset contains the historical time series data for the NASDAQ Composite Index between 2014 to 2024. 

To add a trend line to a line chart visual in Tableau, follow the instructions below:

Step 1: Open your Tableau Desktop on your machine and import the NASDAQ Composite Time Series dataset using the file navigator. 

Trendline in Tableau - Example 1 - Step 1

Step 2: Click on the New Worksheet icon. It will navigate you to a new worksheet.

Step 3: In the new worksheet, drag Year to the Columns shelf and Close/Last to the Rows shelf, respectively. Tableau will create a line chart, as shown in the view.

Trend line in Tableau - Example 1 - Step 2

Step 4: Click on the down arrow next to the SUM(Close/Last), and from the context menu, choose Measure(Sum) – Average.

Trend line in Tableau - Example 1 - Step 4

It will update the visual in the Tableau view.

Trend line in Tableau - Example 1 - Step 4 - updated Visual

Step 5: Navigate to the Analytics pane. Drag the Trend Line visible under the Model section to the Tableau view and then drop it into the Polynomial trend line model type.

Trend line in Tableau - Example 1 - Step 4

As you can see, Tableau has added a polynomial trend line to the line chart in the Tableau view as shown below.

Trend line in Tableau - Example 1 - polynomial Trend line

Example #2 – Customizing the Trend Line

In this example, we will add a trend line and customize it to fit into our visualization in Tableau. For this purpose, we will use the Superstore dataset, which contains the sales details across multiple segments, categories, and subcategories across four different regions in different cities of the US. 

To customize a trend line in Tableau, follow the instructions below:

Step 1: Import the Superstore dataset into Tableau using the File Navigator, as shown below.

Trendline in Tableau - Example 2 - Step 1

Step 2: In the new worksheet, drag Sales to the Columns shelf and Profit to the Rows shelf, respectively. Tableau will create a line chart, as shown in the view.

Trendline in Tableau - Example 2 - Step 2

Step 3: Drag the Sub-Category to the Color and Region to the Detail on the Marks card. This will create a scatter plot as shown below.

Trend line in Tableau - Example 2 - Step 3

Step 4: Navigate to Analytics, drag Trend Line to the Tableau view and drop it on the Linear Model type.

Trend line in Tableau - Example 2 - Step 4

Tableau will add trend lines to the view for each sub-category, which can be identified as per the color coding. 

Trend line in Tableau - Example 2 - Step 4 - category

Step 5: Right-click on the trend line and select Describe Trend Line.

Trendline in Tableau - Example 2 - Step 5

Tableau will open a Describe Trend Line screen, as shown below, highlighting the trend line’s statistical details.

Trend line in Tableau - Example 2 - Step 5 - statistical

Step 6: Right-click on the trend line and choose Edit All Trend Lines.

Trendline in Tableau - Example 2 - Step 6

Step 7: In the Trend Lines Options screen that opens, change the Model Type from Linear to Exponential and click on OK.

Trendline in Tableau - Example 2 - Step 7

This will change the trend line as shown below in the Tableau view.

Trend line in Tableau - Example 2 - Step 7 - change trendline

Example #3

In this example, we will add an exponential model trend line to Tableau using the Europe Sales Records dataset. The Europe Sales Records dataset contains the sales details of different Item types across different Europe regions along with the revenue, sales, cost, and other details. 

To add an exponential model trend line in Tableau, follow the instructions below:

Step 1: Import the Europe Sales Records dataset using the File – Open navigator in Tableau Public or Desktop.

Trendline in Tableau - Example 3 - Step 1

Step 2: In a new worksheet, drag Unit Price to the Columns shelf and Unit Cost to the Rows shelf respectively. Similarly, drag the Item Type to the Color on the Marks card. Tableau will create a scatterplot chart as shown in the view.

Trendline in Tableau - Example 3 - Step 2

Step 3: Navigate to the Analytics pane. Drag the Trend Line to the Tableau view and drop it on the Exponential model type.

Trendline in Tableau - Example 3 - Step 3

Tableau will add an exponential trend line to the scatterplot in the Tableau view as shown below.

Trendline in Tableau - Example 3 - Step 3 - scatterplot

Important Things to Note

  • Trend lines can be added to those visuals that have both axes with numeric values. For non-numeric or date hierarchies values, you can’t add trend lines.
  • Any date formats with ‘m/d/yy’ and ‘mmmm yyyy’ values are supported in trend lines.
  • For visuals where the trend lines are turned on but later modified to a view that doesn’t support trend lines, you will not be able to view the trend line options for the visuals. 
  • For exponential models, confidence lines are not supported in Tableau.
  • If you are using the Show Trend Lines in Tableau option under the Analysis menu, trend line options will be retained in Tableau Desktop. However, trend line options revert to defaults in case you close the workbook with trend lines turned off.

Frequently Asked Questions (FAQs)

1. Can I show confidence bands with my trend lines in Tableau?

Yes, you can show confidence bands with your trend lines in Tableau. You can do so by enabling the Show Confidence Bands option on the Trend Lines Options screen when you edit a trend line. By default Tableau confidence band shows upper and lower 95% confidence lines when you add any trend line in the view.

2. How to handle outliers when fitting trend lines in Tableau?

To handle outliers when fitting trend lines in Tableau, you may follow the below strategies

Identify any outliers by using data visualization such as box plot or scatter plot
Exclude any outliers from your dataset by applying filters in the Tableau view
Apply data transformation techniques to reduce the noise from the data outliers
You can use statistical methods such as regression for fitting trend lines in Tableau.

3. Can I include trend lines in dashboards and story points?

Yes, you can include trend lines in dashboards and story points in Tableau. By adding the trend lines, you can perform trend analysis and forecasting on the data points.

4. Can I adjust the confidence interval of a trend line in Tableau?

No, you can’t adjust the confidence interval of a trend line in Tableau. Tableau doesn’t provide any feature to adjust the confidence interval of a trend line. By default, Tableau shows a 95% confidence interval when you add a trend line.

Guide to What Is Trend lines in Tableau. We learn about the different types of trend lines and how to add and remove them with examples. You can learn more from the following articles –

Google Sheets Date Picker

Track Changes In Google Sheets

DELTA Function In Google Sheets

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *

CHATGPT & AI FOR MICROSOFT EXCEL COURSE - Today Only: 60% + 20% OFF! 🚀

X