Tableau Box Plot is useful to graphically visualizing the numeric data, group by specific data. In this article we will show you, How to Create a Box Plot in Tableau 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 Box Plot 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 Box Plot
In this example, we are going to create a boxplot in Tableau. For this, first drag and drop the Sales Amount from Measures Region to Rows Shelf, and Color from Dimensions region to Details field present in Marks Shelf.
Tableau intelligence will automatically creates the Bar Chart, but we want to create a Box plot so, please select the Box plot option from the Show Me window as shown below
From the below screenshot you can see the Boxplot.
Let me drag and drop the English Country Region Name from Dimensions Region to Columns Shelf. This will create a box plot for each country
You can hover over the mouse on box plot to see the Median, Upper Quartile, Lower Quartile, and the Whisker values.
Change Colors of a Tableau Box plot
In this example we will show you, How to change the Box plot box colors. Tableau provides two different approaches for this.
First Approach: Please right click on the box plot and select the Edit.. option from the context menu.
Once you select the Edit.. option, a new window called Edit Reference Line, Band, or Box will opened to style the box plot.
Second Approach: Go to Format Menu, and select the References Lines…. This will open the Format Reference Lines tab as shown below.
Let me change the Fill color to Red pallet.
Next, we are changing the tableau box plot Border width, and border color
Lastly, we are changing the Whiskers width, and color
Change Colors of a dots in Tableau Box Plot
In this example we will show you, How to add colors to the dots in box plot. For this, drag and drop the English Country Region Name from Dimensions Region to Color field in Marks Shelf as shown below. It means, each country has its own color
Change the SIze of a dots in Tableau Box Plot
In this example we will show you, How to change the dots size in box plot. For this, drag and drop the Order Quantity from Measures Region to Size field in Marks Shelf as shown below.
Create Categorical Box Plots in Tableau
In this example we will show you, How to create a box plot for each color within a region. For this, drag and drop the Color from Dimensions Region to Columns Shelf. By default, box plot will display the horizontal lines (or dots) and they are the compressed box plot. This is because, it is difficult to draw the box plots for an aggregated data so, lets remove the aggregated measure by unchecking the Aggregate Measures available in Analysis Menu as shown below.
Now you can see the box plot for each color present in a region.
Horizontal Tableau Box plot
In this example we will show you, How to change the default vertical box plot into horizontal box plot by swapping rows and columns
Below screenshot will show you the horizontal box plot
Thank You for Visiting Our Blog