Line charts in Tableau – Exploring Charts, Graphs, and Dashboards

Another simple use case for Tableau and Salesforce is to track campaigns over time. In this specific example, we would like to track how much we spent on our campaigns versus the budget we set. To do so we will start by selecting Actual Cost in Campaign from our Measures list and drag it into Rows as shown in Figure 4.9:

Figure 4.9: Tracking campaign costs compared to budget using Tableau and Salesforce

This has now created a vertical bar chart. And while we now know that we have spent almost £35,000 on our campaigns, we need more information. Therefore, we will now select Budgeted Cost in Campaign and drag it on the Actual Cost in Campaign axis. The cursor will change to show two green bars, as shown in Figure 4.10:

Figure 4.10: A vertical bar chart comparing Budgeted Cost and Actual Cost in Campaign

We will now drop our field onto the axis, and Tableau will add this measure to the visualization so that we will now see the Actual Cost and the Budgeted Cost side by side in two bars as shown in Figure 4.11:

Figure 4.11: Side-by-side bars showing Actual Cost and Budgeted Cost

To facilitate comprehension, Tableau will automatically assign a different color to each measure. So now we know that our budgeted and actual expenses align, but was that the case throughout the campaigns?

To answer this final question, we will select End Date and drop it on top of the Measure Names pill in Columns as shown in Figure 4.12:

Figure 4.12: End Date dropped onto Measure Names in Columns for final question resolution.

Tableau will by default choose to display the year of the date of our choice. It may make sense in some cases, but not in this one. Therefore, we will click on the End Date blue pill and select the second month on the list as shown in Figure 4.13:

Figure 4.13: Choosing the second month on the End Date blue pill in Tableau.

We will discuss dates in Tableau in the next chapters, where we will go through more complex visualizations. After you have selected the correct date, your chart will look as in Figure 4.14:

Figure 4.14: Exploring dates and charting in Tableau’s next chapters

We can now see that while we started below our budget, as the campaign progressed, we went over our planned expense. It is probably good that our campaigns did not run for long.

Using ‘Show Me’ menu and bar charts – Exploring Charts, Graphs, and Dashboards

The quickest way for a beginner to start creating visualizations in Tableau is to use the Show Me menu, which will showcase a range of ready-made charts and the combinations of Dimensions and Measures you will need to create Figure 4.2:

Figure 4.2: A beginner’s guide: Explore Tableau’s Show Me menu for effortless chart creation

For example, to answer a question like who my largest customer is, you can select Account Name, hold CTRL, and select Annual Revenue, then click on Horizontal Bars in the Show Me menu, as shown in Figure 4.3:

Figure 4.3: Selecting account name and annual revenue, then choose horizontal bars

Tableau will recommend which chart to use with a border. This time, we will agree with the recommendation.

Figure 4.4: Tableau chart

So, this is your first Tableau chart (Figure 4.4). It looks strange, but we wanted to know who our largest customers were. To do that, we need to sort our chart so that the customers with the largest revenue are at the top.

There are several ways to do that; for now, we will click on the Sort button above the columns/rows area, as shown in Figure 4.5:

Figure 4.5: Clicking on the sort button to organize columns/rows

Our chart looks as shown in Figure 4.6:

Figure 4.6: Account chart

It seems that we have a lot of customers with the same level of revenue, so this is probably not the most insightful chart we could create. But with Tableau, we are never more than a few clicks away from finding more information. For example, which industries bring the largest revenue?

To answer that question, we will select the Industry field and drag it on top of the Account Name field in the Rows panel.

We now have a much better-looking chart as shown in Figure 4.7:

Figure 4.7: Better chart

After sorting it in descending order as we did before, this is what our chart looks as shown in Figure 4.8:

Figure 4.8: Descending sorted chart.

We now know that Engineering and Apparel are the largest industries by revenues, with Energy being a distant third.

Fundamentals of creating visualizations in Tableau – Exploring Charts, Graphs, and Dashboards

This section aims to equip you with the fundamental knowledge and techniques needed to navigate Tableau’s interface and leverage its capabilities to create compelling visualizations. Starting with the Data Source screen and moving into the creation of various chart types, we will explore key concepts such as Sheets, Dashboards, Dimensions, Measures, and more. By understanding these foundational elements, you will be well on your way to effectively visualizing your data, from basic charts to more complex analyses. Whether you are analyzing customer data, tracking campaign performance, or exploring financial metrics, this guide provides a step-by-step approach to harnessing Tableau’s potential to uncover valuable insights hidden within your data.

Now that you have fixed your data to the best possible quality, it is time to start visualizing it. From the Data Source screen, click on Sheet 1. This is the working space where you will create your visualizations. Before we start, it is useful to get acquainted with the following terminology:

  • Sheet/Worksheet: A sheet is a container for each chart in Tableau. Each chart requires a different sheet. We will use the terms sheet and worksheet interchangeably.
  • Dashboard: A collection of sheets displayed at the same time covering related information.
  • Dimensions: These are the categorical variables or the fields you will want to use to slice and dice your data. An example of a dimension can be color, country, name, or surname. Dimensions in Tableau, are blue.
  • Measures: These are the numerical variables, that is, the actual numbers you want to show. For example, sales, number of customers, or profit. Measures in Tableau are green.
  • Field: It is either a dimension or a measure. This word will be used when the dimension/measure distinction does not matter.
  • Mark: Every single point in your visualization is a mark. Each bar in your bar chart, each dot in a scatter plot, and each value in a table is a mark.

Now that we have clarified the basics let us take a look at some of the areas in Figure 4.1:

  1. Data: This shows the data source being used currently. When you start using several data sources across several sheets, it is always a good idea to check that the one you are using in each sheet is correct.
  2. Fields area: This lists all your dimensions and values, which you will use to create your visualizations. At the top, there is a handy filter box for searching a specific field.
  3. Columns/Rows: This is where you will drag your fields to create your visualizations. Different dimensions and measures in different columns/rows arrangements give different charts.
  4. Filters: Every field you use to filter your data, will be shown in this area.
  5. Marks: Here is where you control the aspect of your charts. From here, you can select color, size, and how your labels should look. This area will become increasingly useful as we look into intermediate and advanced charts.
  6. Show me: This is the menu helping beginner users create their charts. Once you stop relying on this menu, you know you will have succeeded in the task of learning to use Tableau.
  7. New Worksheet/Dashboard/Story: Clicking on each of these buttons will create new sheets/dashboard/stories.
  8. Chart area: This is where you will see your visualization. You can also drop fields in this area rather than in the columns/rows area to create charts.

Figure 4.1: Chart area: Visualize and create charts by dropping fields in this area

Introduction – Exploring Charts, Graphs, and Dashboards

This chapter will provide guidance about visualizing Salesforce CRM data in Tableau. We will start with a section on things to remember when visualizing Salesforce data, such as understanding CRM data and the types of analysis you may want to perform. The chapter will then cover the basics of creating visualizations in Tableau, such as using the Show Me menu and creating simple charts.

Structure

The chapter covers the following topics:

  • Fundamentals of creating visualizations in Tableau
    • Using ‘Show Me’ menu and bar charts
    • Line charts in Tableau
    • Tables in Tableau
    • Pie charts in Tableau
    • Treemaps in Tableau
    • Scatterplots in Tableau
  • Bringing all your insights together in a dashboard

Objectives

By the end of this chapter, learners will be able to understand why and how CRM data is crucial for data analysis and decision-making. Specifically, they will be able to recognize different types of analyses that can be performed on Salesforce CRM data, how these might dictate different visualization approaches, and comprehend the factors to consider when visualizing CRM data, including strategies to avoid common visualization pitfalls. They will also familiarize themselves with the key functionalities of Tableau’s “Show Me” menu and basic chart creation techniques. Finally, they will be able to create meaningful visualizations using Salesforce CRM data in Tableau and develop the skills necessary to interpret visualizations effectively, drawing out actionable insights from data presented in visual form.

Unions – Building and Integrating Data Pipelines

It is not possible to union data using the Salesforce connector, so the steps below will only be available if you are connecting to your Salesforce data via a database connection as shown in the section Connecting to your Salesforce data in SQL.

A union works differently from the methods shown above in that, rather than adding columns from different data sources, it adds rows to existing data. In order for unions to work, all data objects must have the same structure.

The steps to perform in this case are the following:

  1. Connect to the database as shown in the section Connecting to your Salesforce data in SQL.
  2. Drag the New Union button to the main data area, as shown in Figure 3.34:

Figure 3.34: Adding a new union in Tableau

  1. A menu will open, as shown in Figure 3.35:

Figure 3.35: Creating union

  1. Drag here all the objects to be unioned. Tableau will read the structure of the first object and expect all objects to follow the same structure, as shown in Figure 3.36:

Figure 3.36: Selecting data sources to union in Tableau

  1. If Tableau encounters no problem in unioning the data, you will see the final dataset at the bottom of your screen.
  2. You can always add or remove objects by clicking on the caret on your union and clicking Edit Union, as shown in Figure 3.37:

Figure 3.37: Final unioned dataset shown in Tableau

  1. The same menu will open. From this same menu you can specify whether the field names are in the first row of your data or whether Tableau should generate field names automatically. The option to choose will depend on how your data is structured.

Conclusion

In this chapter, we have explored various methods for connecting to data in Tableau and delved into the software’s data cleaning and transformation capabilities. You have learned how to connect to Salesforce data using the Salesforce Connector and how to authenticate and configure the connection successfully.

We also discussed connecting to data that has been exported to an SQL database and highlighted scenarios where this method may be beneficial. Furthermore, we have equipped you with the skills to manipulate data in Tableau using techniques such as pivot, join, and split once the data is loaded into the software.

In addition, we have covered managing data sources in Tableau, including connecting to multiple data sources, creating data source filters, and crafting calculated fields. With the knowledge and skills gained from this chapter, you are better prepared to effectively connect to, clean, and transform data in Tableau for enhanced data analysis and visualization. This will ultimately enable you to make more informed decisions and drive impactful insights from your data.

In the next chapter, we will delve into the core functionality that makes Tableau such a powerful visualization tool.

1 Disclaimer: You may not be able to see the color of the ticks change if you have brought a paperback version of the book. However, you can access the colored version of the image at the link given at the beginning of the book.

Blends – Building and Integrating Data Pipelines

Data blends are useful in the case of data sources that have a limited relationship to each other and are used together for only some parts of the analysis and are kept separate for the remainder.

To blend a data source, follow these steps:

  1. Add a data object to the main area.
  2. Go to your visualization sheet.
  3. Click on the Data menu at the top of your screen, as shown in Figure 3.23.

Figure 3.23: Accessing the Data menu in Tableau

  1. Click on New Data Source.
  2. Select the desired data source type and follow the prompts. For this example, we have chosen the Salesforce Superstore data, as shown in Figure 3.24:

Figure 3.24: Adding a new data source in Tableau

  1. You will now see two different data sources in the top left corner of your data menu, as shown in Figure 3.25:

Figure 3.25: Two different data sources are visible after adding a new one

It is now time to define how the data sources should be blended. In order to do so:

  1. Click on the Data menu at the top of your screen.
  2. Click on Edit Blend Relationships. A menu will now open, as shown in Figure 3.26:

Figure 3.26: Editing blend relationships in Tableau

  1. In the menu, select which of your data sources should be the primary one. A good rule of thumb is the data source from which you will be taking the most fields, as shown in Figure 3.27:

Figure 3.27: Selecting the primary data source for a blend in Tableau

  1. Below the primary data source selector, you will see a list of fields.
    Tableau will try to populate those whenever possible. However, if these fields are incorrect or missing, you can adjust them by following these steps, as shown in Figure 3.28:

Figure 3.28: Defining relationships between fields in a Tableau data blend

  1. Select Custom from the Automatic/Custom selector.
  2. Click on a field (if present).
  3. Choose one of the options in the menu at the bottom:
    • Add: To establish a relationship between two fields.
    • Edit: To edit the relationship between two fields.
    • Remove: To remove the relationship between two fields.
  4. Clicking on any of these options will open a menu from where you can pick a field from the primary data source list and its counterpart in the secondary data source field
  5. In this case, we have added the Billing State/Province from Salesforce and matched it with State/Province in the Salesforce data. We have also kept the Segment to Segment match, as shown in Figure 3.29:

Figure 3.29: Mapping fields between two data sources to create a Tableau data blend

  1. Click on OK.
  2. If your blend is successful, you will notice the following changes:
    • Your primary data source has a blue tick next to its name.
    • Your secondary data source has an orange tick to its name, as shown in

Figure 3.30: Indicators of a successful Tableau data blend

  • The field(s) used for the blend have a chain icon next to their name.

You can turn the blend on and off by clicking the chain icon. Two linked chain rings indicate that the blend is currently active, and a barred chain icon indicates a currently inactive blend, as shown in Figure 3.31:

Figure 3.31: Chained versus barred chain icons indicating blend status

Troubleshooting tip

If you cannot see the changes, start dragging fields into the main visualization area. Tableau will treat the data source containing the first field you will use in the visualization as the primary one. For example, here, we have started by dragging the Industry field from the Salesforce data and only afterward added the Segment field from Superstore. So now you can see a blue tick next to Salesforce, as shown in Figure 3.32:

Figure 3.32: Tableau interpreting the first visualized field’s data source as primary in a blend

In this case, we started with the Superstore data and dragged Salesforce data afterward. The blue tick is now on the Superstore data, and the orange is on Salesforce, as shown in Figure 3.33:

Figure 3.33: Tableau interpreting the first visualized field’s data source as primary in a blend1

Blends work regardless of the data source type, as you can see in this case, where the Salesforce data is being blended with the standard Tableau Superstore data, which comes as an Excel .xls file. They are a good solution when dealing with different data types, as in this case, but can quickly encounter performance issues.

Relationships – Building and Integrating Data Pipelines

Introduced in 2020.2, relationships are a new way of connecting different data objects. While joins happen on the physical layer of the data source, relationships happen at the logical layer. This means that there is no new data source created, and Tableau will automatically handle duplicates and null values.

Relationships are the default way used by Tableau to connect data objects. Therefore, the process of using relationships requires fewer steps than joins. To start using relationships with your tables, follow these steps:

  1. Drag a table from the left side of the screen.
  2. Drag the second table you wish to join from the left side of the screen.
  3. If Tableau has enough information, it will set up an automatic relationship.
  4. If Tableau cannot establish a relationship automatically, it will highlight the problem just as it finds a link. It will highlight the problem with a triangle, as shown in Figure 3.20:

Figure 3.20: Tableau indicating it cannot automatically create a relationship between two tables

  1. If that is the case, you can use the menu at the bottom of your screen to specify which fields should be used to establish the relationship.
  2. Just as before, the join is configured so that Tableau can use the table Account with the table Contact by using the field Account ID present in both tables but labeled as Account ID (Contact) in the Contact table, as shown in Figure 3.21.

Figure 3.21: Manually defining the relationship in Tableau using the relationship editor

  1. As you can see, the red triangle mark has disappeared, and the two tables are now joined. This process can be repeated on as many objects as necessary. Simply drag any additional table into the join area, as shown in Figure 3.22, and proceed with the steps defined above.

Figure 3.22: Multiple tables successfully related in Tableau

To remove a table, follow the same steps outlined in the Joins section.

Joins versus relationships

At first glance, it may seem that relationships and joins are quite similar, if not identical. However, there are differences in their substance and behaviors worth understanding to decide which option to use.

The obvious advantage of relationships is that they do not require any prior understanding of SQL-like join behavior, which makes them a great option for beginner users. Advanced users, however, may prefer the additional degree of flexibility that comes from defining which type of join to employ and which fields to use.

It is also worth mentioning that relationships may not work as intended for data where the quality is exceptionally poor and may cause performance issues if large quantities of data are needed.

Joins– Building and Integrating Data Pipelines

Tableau makes it easy to join different tables by working out whenever it can on which fields the tables should be joined.

To start joining tables, follow these steps:

  1. Drag a table from the left side of the screen.
  2. Double-click on the table name, and a small menu will open.
  3. Drag the second table you wish to join.
  4. If Tableau has enough information, it will automatically select an inner join on all the fields found in both tables. If this is correct, you do not need to make any changes.
  5. If Tableau cannot find a link, it will highlight the problem with an empty Venn Diagram and a red exclamation mark, as shown in Figure 3.15:

Figure 3.15: Tableau indicating it cannot automatically join two tables

  1. In the cases where Tableau cannot automatically join the tables or if the default option is not the one you need, please follow the steps below:
    a. Click on the join icon to open the join menu. From here, you can select the following options:
    • The field on the left side table to use in the join.
    • The type of join, which can be an inner join, a left outer join, a right outer join, or a full join. These kinds of join work exactly as they would in SQL.
    • The field in the right-side table to use in the join.
    • A calculated field can also be used in a join. To create one, click on “Create Join Calculation” and proceed to create the field you need. More information on calculated fields will come in a separate section.

In the case below shown in Figure 3.16, the join is configured so that Tableau can use the table Account with the table Contact by using the field Account ID present in both tables but labeled as Account ID (Contact) in the Contact table.

Figure 3.16: Manually defining the join in Tableau using the join menu

As you can see, the red exclamation mark has disappeared and the two tables are now joined. This process can be repeated on as many objects as necessary. Simply drag any additional table into the join area, as shown in Figure 3.17, and proceed with the steps defined above.

Figure 3.17: Multiple tables successfully joined in Tableau

To remove a table, follow these steps:

  1. Hover on the table name
  2. Click on the caret on the left side of the table name. A menu will open, as shown in Figure 3.18:

Figure 3.18: Removing a table from the join in Tableau

  • Click on Remove.

The table has now been removed from the join. You can see that the number of tables in Account has changed from 2 to 1, as shown in Figure 3.19:

Figure 3.19: The join table count is decreasing after removing a table