Session 4.5
Session 4.5
When you bring a measure into a view, Tableau automatically aggregates the values in that
field and represents it according to the level of detail in the view. When you bring two
measures into the view, Tableau also aggregates the measures and finds a point where the
aggregations intersect.
But, what if changing the default aggregation of a measure does not meet your needs? For
example, maybe you want to compare the total and average sales within a single view, or you
want a field that shows average sales to reuse in multiple views.
In cases like these, you can use an aggregate function in a calculation to create the calculated
field, Average Sales.
First create the calculation without aggregating the fields, change the number format from a
decimal to a percentage, and then aggregate each field in the calculation to see how the
results change.
4. Set the Profit Ratio field’s format as a percentage with 1 decimal place.
1. In the Data pane, right-click Profit Ratio, point to Default Properties, and
then click Number Format.
2. In the Default Number Format [Profit Ratio] dialog box,
click Percentage and set Decimal places to 1.
3. Click OK to apply the change and close the dialog box.
5. Use the view you’ve assembled so far to answer the following question.
Knowledge Check 5.2
1. According to the row-level calculation you created, what is the lowest profit
percentage in the view?
a. 1874.5%
b. 1486.6%
c. 14.9
d. 42912.7%
6. Edit the Profit Ratio calculated field to aggregate Profit and Sales separately. Then
drag the edited Profit Ratio field to the Marks card and drop it directly over the
previous calculation to replace it and repair the view.
1. In the Data pane, right-click Profit Ratio, and click Edit.
2. In the calculation editor, edit the calculation to: SUM ([Profit]) / SUM
([Sales])
3. Click OK. The field on the Marks card will turn red, and the view will fade.
4. From the Data pane, drag the edited Profit Ratio field to the Marks card and
drop it on SUM(Profit Ratio), replacing it.
Note: In Tableau Desktop, the field will remain formatted as a percentage. In
Tableau Server and Tableau Cloud, you will need to reformat it as a
percentage.