What is a Marimekko chart and how to create one in Tableau
A Marimekko chart is similar to a stacked bar chart, but also uses varying widths of bars to communicate additional information about the data.It is also known as Mosaic plot or simply Mekko chart.They can be defined as a combination of a 100% stacked column chart and 100% stacked horizontal-bar chart using a different variable for each.They add a visual pop and are ideal for representing categorical sample data.
For example, the Marimekko chart above shows the breakdown of sales by region and segment.The width of the bars tells the total sales for the region whereas the height of each section gives the percentage of sales for that particular segment within the respective region.
Let us see how we can create this chart in Tableau.Here, I have used the Sample — Superstore data for creating the chart.
STEP 1: Open the tableau and load the data.Once done, in the new worksheet drag Region and Segment to rows and Sales to Text. You should see the following:
STEP 2: Next we need to calculate the percentage of sales for each Segment within the Region.To achieve this, right click the ‘SUM(Sales)’ field under the Marks card and click on ‘Add Table Calculation’. In the pop up box change the Calculation Type field to ‘Percent of Total’ from the drop down. In the Compute using field click on the ‘Specific Dimensions’ and uncheck the ‘Region’. Once done close the box and this is how it should appear:
STEP 3: Double click on the ‘Measure Values’ in the Data Pane.This is done so that we can bring in more measures for the chart.
STEP 4: Next we need to calculate the total sales in each region. For this we need to create a calculated field ‘Region Sales’ using the FIXED LOD expression as below:
{ FIXED [Region]:SUM([Sales])}
Once done, drag the ‘Region Sales’ under the Measure Values.
STEP 5: Next we need to Calculate the Running total of Region and drag it under the Measure Values.For this we need to create a Calculated field ‘Running Total Region’ as below:
IF FIRST() = 0 THEN MIN([Region Sales])
ELSEIF MIN([Region]) <> LOOKUP(MIN([Region]),-1) THEN PREVIOUS_VALUE(0)+MIN([Region Sales])
ELSE PREVIOUS_VALUE(0)
END
Explanation:
FIRST() function assigns the values 0,-1,-2… to row 1,2,3… respectively in the partition. Here the FIRST() = 0 expression is used to check if the row is the first row.
If found true, the value in the ‘Region Sales’ of that particular row is populated as the ‘Running Total Region’.
If found not true then, ‘Region’ value of the row is evaluated against the ‘Region’ value of the previous row using LOOKUP function.
If found different, it will add the row ‘Region Sales’ to the previous row ‘Region Sales’ to populate the ‘Running Total Region’ value of that row.
If not found different it will simply populate the previous row ‘region Sales’ to ‘Running Total Region’ value of the row.
Please note: The MIN is used in the calculated field to avoid errors as Tableau does not allow non aggregate fields in the table calculation functions. Other than that it doesn’t have any significance in the results of the calculation.
Once done this is how the sheet would appear:
STEP 6: Now all the required values and calculations are created. Next is to rearrange the fields one by one to create the chart. First we need to drag and drop the Measure values from Text to Details under the Marks section.This is how it would appear then.
STEP 7:We can also remove the Measure Names from Column section.
STEP 8:We can now drag the Segment and Region from Row section into details under Marks section.This is how it will appear:
STEP 9:Next we need to move SUM(Sales) with table calculation in Measure values to Rows and the ‘Running Total Region’ calculated field in Measure Values to Columns.We would get a scatterplot since they both are measure values Tableau automatically assigns that.
STEP 10: Let us manually change it into bar graph from the drop down list in the Marks section.This is what we get once done:
STEP 11: Next drag SUM(Region Sales) to Size under the Marks section.Next click on the ‘Size’ box under the Marks and change Manual to Fixed option and the Alignment option to Right.This is how the screen would appear now:
STEP 12: Next drag the Segment to Color.
STEP 13: We need to click on the drop down on the ‘SUM(Sales)’ field, click on Compute Using and select ‘Segment’. Similarly we need to click on the drop down on the ‘Running Total Region’ field, click on Compute Using and select ‘Region’.
STEP 14: Finally drag ‘Region’ field into Text Label. Finish off by changing the name of the sheet to ‘Marimekko Chart’.
There you have it!Hope it was helpful for you!Happy Learning!!!