Include and Exclude

The best way to understand these is with an example. In the following diagram, you can see three measures, according to Category and Sub-Category:

  • A normal aggregation, the maximum of sales: MAX([Sales])
  • An attribute aggregation of a Calculated Measure using an Exclude function: ATTR( { EXCLUDE [Sub-Category]: MAX([Sales]) } )
  • An average aggregation of Calculated Measure using an Include functionAVG( { INCLUDE [Segment]: MAX([Sales]) } )

Here's the result:

Let's spend some time understanding what you see:

  • The first value is a simple aggregation. It returns the highest sales value by Category and Sub-Category, which are the levels of detail in the View.
  • The second calculation, ATTR( { EXCLUDE [Sub-Category]: MAX([Sales]) } ), excludes the Sub-Category from the calculation. The result shows the maximum sales value of the Category, even if the Sub-Category is in the View. The level of detail of the calculation is higher than the level of detail in the View, so Tableau uses the ATTR() aggregation. There are more Marks than returned values, so the same value is repeated multiple times.
  • The third calculation, AVG( { INCLUDE [Segment]: MAX([Sales]) } ), includes the Segment in the calculation. The result shows the averages of the maximum sales by Category, Sub-Category, and Segment. The level of detail of the calculation is lower than the level of detail in the View. An aggregation is needed because the calculation returns more different values than Marks.

You can write all the Include and Exclude functions with Fixed. Let's focus on the third LOD function, which is even more powerful.

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

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