# 9 Lab [en] - Data visalization, LOD, Quick Calculations ###### tags: `Data Visualization` `level of details` `quick calculations` [TOC] # Introduction - exercise objective The purpose of this class is to perform exercises using Tableau's advanced calculation formulas. # 1 Source data The exercise is based on the *"Sample EU SuperStore "* data source built into Tableau. # 2.1 Calculation formulas in Tableau ## 2.1 Quick Table Calculations The system has a built-in library of calculation functions that can be used to define calculation fields, as shown below. ![](https://i.imgur.com/ignYl72.png) The most frequently used calculation formulas have been gathered in a pop-up menu, which allows to quickly call up a predefined calculation formula in the context of a selected measure. ![](https://i.imgur.com/Kws41Ww.png) The following video demonstrates the technique of using *Quick Table Calculations* along with converting predefined formulas into regular calculation fields and editing them. {%youtube 3o_3WRT9OWI %} ## 2.2 Pop-up menus - defining the context in which calculation formulas work When using the built-in, handy *Quick Table Calculations* formulas, we have the ability to define the scope -- context of the formulas used. Using the *Compute using* list available in the pop-up menu (figure below), we can define how the calculation formulas work. ![](https://i.imgur.com/2DzWtGC.png) Slightly more possibilities than the above list are given to us by using the *Edit Table Calculation...* option from the popup menu, which brings up the dialog as shown below. ![](https://i.imgur.com/uOUEkAk.png) An example use of the options described above is illustrated in the video below. {%youtube UeFOCJJmq4I %} ## 2.3 Level of details - level of details analysis in Tableau There are three Level of details (*LOD*) expressions available in Tableau: * FIXED, * INCLUDE, * EXCLUDE. These levels allow you to define how formulas are calculated. ### 2.3.1 FIXED LOD The FIXED level of detail calculates values using selected dimensions, regardless of the dimensions presented in the visualization. :::info **Example**. {FIXED [Region] : SUM([Sales])} ::: shows the sales value regardless of the dimensions shown in the selected view - figure below. The figure shows a table where the sales value is expressed in the context of (for) the region regardless of the State/Province dimension. ![](https://i.imgur.com/OGOKF76.png) When changing the FIXED attribute to State/Province, we get a visualization as in the next figure. ![](https://i.imgur.com/WmtTrTm.png) ### 2.3.2 INCLUDE LOD INCLUDE LOD calculates values using the indicated dimension (in INCLUDE) in addition, relative to the dimensions currently used in the visualization. :::info **Example**. AVG({ INCLUDE [State] : SUM(Sales)}) ::: The expression will calculate the average value of sales in the context of each state. This will be a completely different value than: AVG(Sum(Sales)) - compare in the figure below. ![](https://i.imgur.com/Xx2mOw1.png) The top panel of the above figure shows the average calculated from the LOD expression with the include option set to *State/Province* - the result is the average sales values for the state. The bottom panel plots the relationship *AVG(Sales)*, which is the average sales value calculated from all sales records (without looking at *State/province*). ### 2.3.1. EXCLUDE LOD EXCLUDE LOD indicates the dimensions to be excluded from the visualization. :::info **Example**. {EXCLUDE [Region]: SUM([Sales])} ::: The above example bypasses *Region* when counting the sum. In the figure below, you can see the effect of using such a defined field to improve chart coloring. ![](https://i.imgur.com/tgI9NB1.png) In the figure above, the values for the *region* data series are colored using *SUM(sales)* -- but this does not allow for proper coloring using the full color palette, because the same scale is used for each region. Using *{EXCLUDE [Region]: SUM([Sales])}* for coloring allows you to draw an independent scale for each region, as shown below. ![](https://i.imgur.com/qNzxSOx.png) :::spoiler EXCLUDE LOD is a useful expression for constructing a visualization showing a relationship like "percent of total" or "difference/difference from average". I ask those interested to review the materials available at: [help.tableau.com](https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_lod.htm) ::: # 3 Exercise - mini project > **Packacking waste - analysis of the structure and recycling rates for plastic and glass waste** > > * data source: Eurostat (sample: [Packaging waste statistics](https://ec.europa.eu/eurostat/statistics-explained/index.php?title=Packaging_waste_statistics)) > * sample analysis/report: [BAD-MOUTHING PLASTIC DOESN’T SOLVE ANY PROBLEMS](https://kampus.umcs.pl/pluginfile.php/765865/mod_page/intro/raport%20plastics%20en.pdf) Prepare the short project (3-4 dashboards) in gropus of two that will analyze packaging waste statistics provided by Eurostat and answer research questions: 1. Which packaging waste streams are dominant and how has this changed over last 10 years? 2. Which type of packaging waste: glass or plastic is more common and better recycled in EU countries? 3. Is there a correlation between economic and demographic factors and waste levels in EU countries? ![](https://i.imgur.com/WIiLCeH.png)