The Previous week, we watched the tableau fringe festival at data school down under. One of its speakers was Paul Wachtler and he did a fantastic talk about LoD. In his talk, he talked about context filters and how it works with a nice example. Let me share this for you all.

Step 1. Connect ‘World indicators extract’ data to tableau (one of tableau’s sample dataset)

Step 2. Double click Region and Country and bring it to Rows.

Step 3. Bring Year to filter and click 2012. (We need only data of the year 2012).

Step 4. Double click on Total Population. Now we get the country level total population.

Now we need to get the Region Population. As the total population is at country level we need to make a calculation on region level. We can make it in two ways: by exclude LoD expression or by fixed LoD expression. By exclude LoD we are excluding the country level population and aggregating it in Region level.

If we need to compare our country’s population with respect to the world population in 2012. Then we need a calculated field.

Here we get the total world population. It has not filtered based on the year 2012. Here comes the concept of context filters. We get the total population because Fixed LoD expression is computed before the Year dimension is considered. So that’s one-way order of operations matters. To resolve this problem either we can make the year as a context filter by clicking the Add to context.

Now we get the world population of 2012.

Or we can change the Fixed expression as {fixed [year]: sum [Population Total]}

Meera Vijayan
Author: Meera Vijayan