Understanding INCLUDE LOD

As mentioned earlier, the INCLUDE LOD expression, computes values using the specified dimensions in addition to whatever dimensions are present in the view. These expressions are most useful when including a dimension that is not part of our view as the results are computed at a lower granularity than the visualization's level of detail.

The syntax of using an INCLUDE LOD expression is { INCLUDE [Dimension] : aggregate expression}.

The preceding syntax shows how one can use an INCLUDE expression for a single dimension, however, if there is more than one dimension that we want to include in our calculation, then the syntax can be modified as { INCLUDE [Dimension1], [Dimension2], [Dimension3] : aggregate expression}.

Let us see how we can use the INCLUDE LOD expression in the following recipe.

Getting ready

Let's use the Sub-Category and Sales fields from the Orders sheet of Sample - Superstore.xlsx data.

How to do it…

  1. Let us create a new sheet by pressing Ctrl + M and rename it INCLUDE LOD.
  2. Let us then drag Sub-Category from the Dimensions pane and drop it into the Rows shelf.
  3. We will then create a new calculation called Average Sales and the formula will be AVG([Sales]).
  4. Let us drag the Average Sales field from the Measures pane and drop it into the Text shelf. Our view will update, as shown in the following screenshot:
    How to do it…
  5. Next we will create another calculation called Include Region-Average Sales and we will type the formula as AVG({INCLUDE [Region]:SUM([Sales])}).
  6. We will click OK and then double click on the new calculated field to fetch it into our view. Our view will then be updated, as shown in the following screenshot:
    How to do it…

How it works…

In the preceding recipe, we created two calculations called Average Sales and Include Region-Average Sales. The first calculation, that is, Average Sales looks at the sum of sales for all records under each sub category and then takes an average at a sub-category level.

However, the second calculation, that is, Include Region-Average Sales looks at the sum of sales at region level even though the region is not part of our view and then takes an average at a sub category level.

To know more about INCLUDE LOD, refer to https://onlinehelp.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_lod_include.html.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.37.38