%
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.
Under Field Properties, click the Display Format option.
In the Display Format interface, select Percentage from the Category menu.
Make the adjustments, as needed:
Click Save.
Here, we are using a basic table visual built in the Cereals dataset.
Populate the shelves from the available fields (Dimensions, Measures, and so on) in the Data menu.
cereal_name
on the Dimensions
shelf.calories
, protein_grams
,
fat_grams
, dietary_fiber_grams
, complex
carbohydrates_grams
, sugars_grams
, and
sodium_mg
on the Measures shelf.Ensure that the aggregation function used by the measure is Average, for calculations in the next step. See Aggregates.
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.
Calories | Protein | Fats | Fiber | Carbohydrates | Sugar | Sodium |
---|---|---|---|---|---|---|
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, change the Display Format to Percentage, select a 2- decimal display, and click Save.
Note that the visual's display has the specified format, the % sign, and 2 decimal places.