Tableau Text Label

In Tableau, we can create Pivot data (also called Text Labels or Crosstabs) by placing one dimension on the Column shelf and another dimension on the Row shelf. Let us see how to Create a Tableau Text Label with an example.

For this Tableau Text Label demo, we will write the Custom Query against the SQL Server Data Source.

I suggest you refer to the Connecting to SQL Server and Charts article to understand the Tableau configurations. The custom SQL query that we are going to use for this report is:

-- SQL Query to create a Text lable in Tableau
SELECT ProdCat.EnglishProductCategoryName, 
       ProdSubCat.EnglishProductSubcategoryName, 
       Geo.EnglishCountryRegionName, 
       Geo.StateProvinceName, 
       Geo.City, 
       Geo.PostalCode, 
       Geo.IpAddressLocator, 
       Prod.EnglishProductName, 
       Prod.Color, 
       Prod.DealerPrice, 
       Cust.FirstName, 
       Cust.LastName, 
       Cust.Gender, 
       Cust.YearlyIncome, 
       Cust.EnglishEducation, 
       Cust.EnglishOccupation, 
       Fact.OrderQuantity, 
       Fact.TotalProductCost, 
       Fact.SalesAmount, 
       Fact.TaxAmt, 
       Fact.OrderDate
FROM DimProductSubcategory AS ProdSubCat
   INNER JOIN
     DimProduct AS Prod ON ProdSubCat.ProductSubcategoryKey = Prod.ProductSubcategoryKey 
   INNER JOIN
     DimProductCategory  AS ProdCat ON ProdSubCat.ProductCategoryKey = ProdCat.ProductCategoryKey 
   INNER JOIN
     FactInternetSales AS Fact ON Prod.ProductKey = Fact.ProductKey 
   INNER JOIN
     DimCustomer AS Cust ON Fact.CustomerKey = Cust.CustomerKey
   INNER JOIN
     DimGeography AS Geo ON Cust.GeographyKey = Geo.GeographyKey

Create a Tableau Text Label

In this example, we will create a text label in Tableau. For this, first, drag and drop the English Product Subcategory Name from Dimensions Region to Rows Shelf and Order Date (Year) to Column Shelf.

Tableau Text Label 1

Next, drag and drop the Sales Amount from the Measures Region to the Text field present in the Marks Shelf.

Tableau Text Label 2

From the above screenshot, we don’t have much data for the years 2010 and 2011. So, we excluded those years by selecting those columns in a report and choosing the Exclude option from the tooltip.

Tableau Text Label 3

Next, drag and drop the English Country Region Name from the Dimensions section to Rows Shelf on the left side of the product subcategory.

Tableau crosstab report 4

The above screenshot shows the complete Tableau Text Label crosstab report. Let us interchange the positions of the dimensions in the Row shelf.

Tableau Text Label 5

Here, we replaced the product subcategory name in the row shelf with the color dimension.

Tableau Text Label 6

Add Table Calculation to Tableau Text Label

To add the table calculation as a text label, please select and right-click on the Sales Amount measure (change as per your requirement), which will open the context menu. You must choose the Add Table Calculation option, as shown below.

Add Table Calculation of crosstab report 7

Once you select the Add Table Calculation option, a new window called Table Calculation will open. Here, we choose the Calculation Type as the percent of the Total and Computed by Table (crosstab). Remember, we will discuss the Table calculations in another article, and here, we will only focus on the crosstabs report.

Change Table Calculation to Percent of Total 8

The following screenshot will show you the Tableau text label, Crosstab report, and the Percentage total. As you can see, we got the maximum percentage of sales in 2013 compared to 2012 and 2014.

Tableau Text Label 9