Percentage Display Formats

Tip. The % 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.

  1. We are using a basic table visual built in the Cereals dataset.
  2. Populate the shelves from the available fields (Dimensions, Measures, and so on) listed in the left navigation menu.

    • Under Dimensions, select cereal_name and place it on the X shelf.
    • Under Measures, select calories and place it on the Y shelf.
    • Similarly, select protein_grams, fat_grams, dietary_fiber_grams, complex carbohydrates_grams, sugars_grams, and sodium_mg from Measures, and place them on the Measures shelf.
  3. [Optional] Use Alias to rename the fields on the shelf to % Daily Calories, % Daily Protein, and so on.
  4. 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.

  5. 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.

    Recommendations for Daily Dietary Intake
    2000 cal50 grams70 grams30 grams310 grams90 grams2300 milligrams
  6. 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.

  7. In the Display Format modal window,

    • Under Category, select Percentage.

      Notice that this action adds a Decimal Places option.

    • [Optional] Under Sample, enter a representative value, to preview the formatting changes.
    • Under Decimal Places, enter 2.

      To see all decimal places, select All.

    • Click Save.
    Applying Percentage Display Format
    Applying Percentage Display Format
  8. Click Refresh Visual.
  9. Note that the visual's display has the specified format, the % sign, and 2 decimal places.