KNOWLEDGE BASE

## Creating a Skyline Chart (Variable Width Column Chart)

Published: 23 Mar 2017

### Question

How to create a skyline chart.

In this article, we will assume that a company has large sales and high profit rate. In order to replicate this we will want to show a large area in the chart by using the following information:
• ​A Skyline chart has measures in both X-axis (Sales) & Y-axis (Profit rate).
• Evaluate by the size of area divided  by X-axis and Y-axis.

### Environment

• Tableau Desktop 10.2.0
• Windows 10
• Excel

### Step 1: Create calculated fields

1. Create a new worksheet called "＠CrossTable"
2. Select the Analysis tab and select Create Calculated Field...
3. Name the calculated field "@SalesWidth", enter the following formula and click OK:
`{EXCLUDE: SUM([Sales])}`
4. Select the Analysis tab and select Create Calculated Field...
5. Name the calculated field "@SalesRightStartPoint", enter the following formula and click OK:
```IF FIRST()==0 THEN
MIN([@SalesWidth])
ELSEIF MIN([Sub-Category]) != LOOKUP(MIN([Sub-Category]),-1) THEN
PREVIOUS_VALUE(0) + MIN([@SalesWidth])
END```

### Step 2: Create a crosstab

1. Build the view as a crosstab
2. Drag Measure Names to the Columns shelf
3. Drag Measure Values to the Text Mark
4. Keep the following measure values:
• SUM(Sales)
• SUM(@SalesWidth)
• @SalesRightStartPoint
• For this measure, ensure the Calculation computes using "Sub-Category"
• AGG(Profit Ratio)

### Step 3: Build the Skyline Chart

1. Duplicate ＠CrossTable and create worksheet called "@SkylineChart"
2. Drag Measure value from Text to Detail
3. Delete Measure name from column (ABC text will be displayed）
4. Drag Sub-Category from Rows to Detail (Squares will be displayed in line)
5. Drag Profit Ratio to Rows (Stacked bar chart will be displayed）
6. Drag "@SalesRightStartPoint" to Columns (Scatter plot will be displayed）
7. Change graph type to Bar Chart
8. Drag "@SalesWidth" to Size
9. Click the size icon mark and Select Fixed > Align Right
10. Delete Measure Value from Detail
11. Drag Sub-Category to Color
12. Right click Sub-Category and sort by Profit Ratio descending.
13. Right click "@SalesRightStartPoint" on Columns and ensure the Calculation computes using "Sub-Category"