%operation automatically multiplies the number by 100. If your data source reports percentages as whole numbers ('2%' is stored as '2' instead of '0.02'), you must divide by 100 first. We recommend that you make this adjustment globally, in the Dataset Attribute Definition interface, as described in Changing Column Calculation.
The following steps demonstrate how to properly use percentages, the
% format option, with display format.
Populate the shelves from the available fields (Dimensions, Measures, and so on) listed in the left navigation menu.
cereal_nameand place it on the X shelf.
caloriesand place it on the Y shelf.
sodium_mgfrom Measures, and place them on the Measures shelf.
Ensure that the aggregation function used by the measure is Average, for calculations in the next step.
On each field on the Measures shelf, click the icon to the right, select Aggregates, and then select Average.
To calculate the percentage of daily recommended intake that a portion of each cereal represents, edit the expression of each field to divide by daily values.
|2000 cal||50 grams||70 grams||30 grams||310 grams||90 grams||2300 milligrams|
Finally, set the display format for the re-calculated fields.
For all the fields on the Measures shelf, click the icon to the right of the variable, and select Display Format.
In the Display Format modal window,
Under Category, select Percentage.
Notice that this action adds a Decimal Places option.
Under Decimal Places, enter 2.
To see all decimal places, select All.
Note that the visual's display has the specified format, the % sign, and 2 decimal places.