Aggregate Level example

One thing you might want for analysis is the Price per Square Foot. This does not exist in the data. This really couldn't have been stored at the source, because the value changes based on the level of detail present in the view (for example, the average price per square foot per building will be different than the average price per square foot per apartment). Rather, it must be calculated at an aggregate level.

Let's create a calculation named Price per Square Foot with the following code:

SUM([Price]) / SUM([Area]) 

This code indicates that the sum of Price should be divided by the sum of Area. That is, all values for Price will be added, all values for Area will be added, and then the division will take place.

Once you click OK in the Calculated Field dialog box, you'll note that Tableau places the new field under measures. Tableau will place any calculation with a numeric result under Measures by default. But in this case, there is an additional reason. Tableau will treat every Aggregate calculation as a measure, no matter what data type is returned. This is because an Aggregate calculation depends on dimensions to define the level of detail at which the calculation is performed. So, an Aggregate calculation cannot itself be a dimension. Note that you are not even able to redefine the new field as a dimension.

Now create a couple of views to see how the calculation returns different results depending on the level of detail in the view. First, take a look at the Price per Square Foot by Building and Floor:

Now notice how the values change when you add in the Unit field:

Why did the values change? Because aggregations, including calculated aggregations, depend on what dimensions are defining the level of detail of the view. In the first case, Building and Floor defined the level of detail in the view, so the calculation added up all the prices for each floor and all the areas for each floor and then divided. In the second case, Unit redefines the level of detail, so the calculation added up all the prices for each unit/floor/building and all the areas for each unit/floor/building and then divided.

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

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