U3 - Tableau
U3 - Tableau
Attribute N/A
Returns the value of the
given expression if it
only has a single value
for all rows in the group,
otherwise it displays an
asterisk (*) character.
Null values are ignored.
This aggregation is
particularly useful when
aggregating a
dimension. To set a
measure in the view to
this aggregation, right-
click (control-click on
Mac) the measure and
choose Attribute. The
field then changes to
show the text ATTR:
● Workbooks
created before
Tableau Desktop
8.2 and that use
Microsoft Excel or
Text File data
sources.
● Workbooks that
use legacy
connections.
● Workbooks that
use Microsoft
Access data
sources.
Calculated Values and Table Calculations allow you to add new data to your Tableau
workbook, but the way you add the data, and where the calculations occur, is different for
each method. Use table calculation functions to customize table calculations. They are
computations/calculations that are applied to the values in the entire table and are
often dependent on the table structure itself.
Calculated Values are defined by entering a formula into Tableau’s formula editing dialog
box. For example, if you have gross margin dollars and sales dollars in your source data,
you may want to add a new field called Gross Margin Percent by creating a calculated
value. The formula to create the gross margin percent is: sum ([ gross margin dollars]) /
sum ([ sales dollars]).
Table Calculations:
Table calculations are the computational workhorse of Tableau. Table calculations are
derived from the structure of the data included in your visualization, so table calculations are
dependent on the source worksheet view contained in your workbook. That means these
calculations are always derived locally by using your personal computer’s processor to
return the result.
Understanding exactly how Table Calculations work takes a little time because Table
Calculations can change as your visualization is altered. As with any new concept, after you
create some Table Calculations you’ll get comfortable with how they behave in different
situations. Tableau’s online manual has a large number of examples where you can view
and get some good basic introduction.
Creating a Table Calculation requires that you have a worksheet with a visualization. A
good way to create them is to right-click on a measure pill used in the view to expose the
Quick Table Calculation menu. Quick Table Calculations are provided for:
● Running total
● Difference
● Percent difference
● Percent of total
● Moving average
● YTD total
● Compound growth rate
● Year over year growth
● YTD growth
Depending on the view of the data included in your worksheet some of these may be
unavailable because your worksheet view doesn’t support the calculation.
Calculated Values:
Calculated Values can be used to generate numbers, dates, date-times, or strings. All
calculated values require the following elements:
Start the formula dialog box via the main menu using the Analysis/ Created Calculated Field
option or by right-clicking on a field . The formula dialog is where you enter the functions,
operators, and parameters to create the logic for your formula. Alternatively, right-clicking a
field in the dimensions or measures, shelves opens the formula dialog box as well, but also
includes that field that is already entered in the formula editing area.
Calculated fields allow you to create new data from data that already exists in
your data source. When you create a calculated field, you are essentially
creating a new field (or column) in your data source, the values or members of
which are determined by a calculation that you control. This new calculated
field is saved to your data source in Tableau, and can be used to create more
robust visualizations.
You can use calculated fields for many, many reasons. Some examples might
include:
● To segment data
● To convert the data type of a field, such as converting a string to a date.
● To aggregate data
● To filter results
● To calculate ratios
You create calculated fields using calculations. There are three main types of
calculations you can use to create calculated fields in Tableau:
● Basic calculations - Basic calculations allow you to transform values or
members at the data source level of detail (a row-level calculation) or at
the visualization level of detail (an aggregate calculation).
● Level of Detail (LOD) expressions - Just like basic calculations, LOD
calculations allow you to compute values at the data source level and the
visualization level. However, LOD calculations give you even more
control on the level of granularity you want to compute. They can be
performed at a more granular level (INCLUDE), a less granular level
(EXCLUDE), or an entirely independent level (FIXED) with respect to the
granularity of the visualization.
● Table calculations - Table calculations allow you to transform values at
the level of detail of the visualization only.
The type of calculation you choose depends on the needs of your analysis
and the question you want to answer.
For Difference From, Percent Difference From, and Percent From table
calculations, you can also specify a different field from which the difference
should be computed. The options are Previous, Next, First, and Last.
● A calculated field that includes more than one calculated field with a
table calculation (as in the example below), or
● A calculated field that itself has a table calculation and includes at least
one calculated field with a table calculation.
With nested table calculations, you can set Compute Using configurations for
individual calculations independently.
Here is a scenario you can try, using the Sample - Superstore data source that
is included with Tableau Desktop, which results in a nested table calculation.
1. Drag Sub-Category to Columns and Region to Rows.
2. Create a calculated field, 1-nest, with the definition
TOTAL(SUM([Sales])).
TOTAL is a table calculation function, so this calculated field
automatically has a table calculation—when you use it in the view, the
field will have the tell-tale table triangle, indicating a table calculation:
1. From the Data pane, under Measures, drag Running Sum of Profit to
Color on the Marks card.
2. On the Marks card, click the Mark Type drop-down and select Square.
The visualization updates to a highlight table:
1. On the Marks card, right-click Running Sum of Profit and select Edit
Table Calculation.
2. In the Table Calculation dialog box that opens, under Compute Using,
select Table (down).
The visualization updates to the following: