In Tableau, we can create Pivot data (also called as Text Labels, or Cross tabs) by placing one dimension in Column shelf, and another dimension in Row shelf. In this article we will show you, How to Create a Tableau Text Label with example. For this we are going to write the Custom SQL Query against the SQL Server Data Source. I suggest you to refer Connecting Tableau to SQL Server article to understand the configurations. The custom SQL query that we are going to use for this report is:
-- SQL Query to create a Text lable in Tableau
FROM DimProductSubcategory AS ProdSubCat
DimProduct AS Prod ON ProdSubCat.ProductSubcategoryKey = Prod.ProductSubcategoryKey
DimProductCategory AS ProdCat ON ProdSubCat.ProductCategoryKey = ProdCat.ProductCategoryKey
FactInternetSales AS Fact ON Prod.ProductKey = Fact.ProductKey
DimCustomer AS Cust ON Fact.CustomerKey = Cust.CustomerKey
DimGeography AS Geo ON Cust.GeographyKey = Geo.GeographyKey
Create a Tableau Text Label
In this example, we are going to 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.
Next, drag and drop the Sales Amount from Measures Region to Text field present in Marks Shelf.
From the above screenshot you can see that, we don’t have much data for the year 2010, and 2011. so, we are excluding those years from the report by selecting those columns and selecting the Exclude option from the tool tip.
Next, drag and drop the English Country Region Name from Dimensions Region to Rows Shelf on the left side of the product subcategory.
Above screenshot will show you the complete cross tab report. Let us interchange the positions of the dimensions in Row shelf.
Here, we replaced the English product subcategory name in row shelf with the color dimension
Add Table Calculation to Tableau Text Label
In order to add the table calculation, please select, and right-click on the Sales Amount measure (change as per your requirement) will open the context menu. here you have to select the Add Table Calculation option as shown below.
Once you select the Add Table Calculation option, a new window called Table Calculation will be opened. Here we are selecting the Calculation Type as percent of Total, and Computed by Table (cross tab). Remember, we will discuss about the Table calculations in another article and here we will focus on cross tabs report only.
Following screenshot will show you the Cross tab report along with the Percentage total. As you can see, we got maximum percentage of sales in 2013 compared to 2012, and 2014.
Thank You for Visiting Our Blog