## I love Marimekko!

I know, these words sound perfectly geeky, I assume. Simple looking, they still encode more information than our traditional pie charts or bars. There are several techniques to build them in Tableau Software. I will give you my solution, it may not be the most optimal but it allows to swap from a vertical version to a horizontal version in one click! I recently used it to visualize human losses during the Great War.

## What is a Marimekko?

The “Marimekko” graph is a kind of 100% stacked barchart that allows to encode one more information: the share of the categories. 100% stacked bars traditionally allow to visualize the relative shares within each category without giving information on the representativeness of the categories. In the usual vertical Marimekko, the horizontal axis encodes the share of each category to the set, the vertical axis the share of each measure within each category. The larger the area, the higher the “population” of the category / measure.

An alternative version is to rotate this visualization. This allows, among other things, annotating and writting labels more effectively. With my Great War Visualization:

- height: the population (number of inhabitants in 1914) for each country involved in the conflict
- in width: the share of losses, injuries and non-injuries/losses for each of these countries.

Effective don’t you think? What do we say?

## Data

Your main data must be formatted like this:

These test data are available on this link:

https://drive.google.com/file/d/1bwBzzzrcGBcyoVlLuV4xBIE3I7P1OqPv/view?usp=sharing

You’re getting used to it, I’m going to use polygons again. I will build each Marimekko rectangle by calculating their coordinates based on the *Value *field.

I need to densify the main data, and therefore duplicate it with a Cartesian product with a model dataset. Again, to improve performance, I advise you to use data filtered and aggregated to the maximum.

The *Link *field allows me to build the Cartesian product. For each initial line, I now have 4 points, ready to accommodate the X and Y coordinates of each 4 points of the rectangles.

## Calculations

Serious things begin, we are going to prepare the intermediate fields which will be used in our final coordinates.

*You can also see the list of calculations by downloading the Tableau Public Viz: *https://public.tableau.com/views/greatified_com-HorizontalMarimekko/Marimekko?:embed=y&:display_count=yes&publish=yes

1.Value : value to use for each category and measure (redefinition of the aggregation because of the Cartesian product)

{FIXED [Category],[Value Name]: min([Value]) }

2.Value Total : sum of values for each category

{FIXED [Category]: sum([1. Value]) }

3.% Value Total : part of each category to the whole

sum([2. Value Total])/TOTAL(sum([2. Value Total]))

4.% Running Value Total : cumulative sum for each category. Will be useful for calculating the next position.

RUNNING_SUM([3. % Value Total])

5.% Value : share of each measure in each category

sum([1. Value])/sum([2. Value Total])

6.% Running Value : cumulative sum of each measure in each category. Will be useful for calculating the next position.

RUNNING_SUM([5. % Value])

7.index : category ID number

INDEX()

8.Nb Category : number of categories

AVG({COUNTD([Category])})

9.index value : ID number of the measure

INDEX()

@X : position of the points on the horizontal axis (to build the rectangles!)

IF ATTR([Point])=1 THEN [6. % Running Value]-[5. % Value]

ELSEIF ATTR([Point])=2 THEN [6. % Running Value]

ELSEIF ATTR([Point])=3 THEN [6. % Running Value]

ELSEIF ATTR([Point])=4 THEN [6. % Running Value]-[5. % Value]

END

@Y : position of the points on the vertical axis (to build the rectangles!)

(IF ATTR([Point])=1 THEN [4. % Running Value Total]-[3. % Value Total]

ELSEIF ATTR([Point])=2 THEN [4. % Running Value Total]-[3. % Value Total]

ELSEIF ATTR([Point])=3 THEN [4. % Running Value Total]

ELSEIF ATTR([Point])=4 THEN [4. % Running Value Total]

END

+[7. index][P_Gap])/(1+[P_Gap][8. Nb Category])

A *P_Gap *parameter is used in this last formula to display the labels between each rectangle.

## Visualization

To build the visualization, nothing more “simple”! I place the *Point *field in Path, *Category *in Detail, *Value Name* in Color. I place *@X* in Columns and *@Y* in Rows. I use the Polygon mark type. Before having the expected visual, it is necessary to define the Table Calculations of these two last fields.

To define Table Calculations, right-click @X and @Y, then set the correct levels for each measure used.

One last step is to reuse the @Y field in double axis, shortcut Ctrl + Drag and Drop in Rows then right click “Double Axes” without forgetting to synchronize the axes. It will be used to display labels on a Circle or Shape mark type.

@display_label : A new field has been created to only display the labels on each first point per category.

IF attr([Point])=1 and [9. index value]=1 then 1 else 0 end

What a great fun we had!

Now you just have to format the final visualization as you see fit!