Sometimes, the data in the base tables cannot be used directly, and must use an expression to "correct" it. Instead of applying this expression in every visual, it can be more effectively applied at attribute level, during dataset definition.
For example, when default percentages are reported as whole numbers instead of fractions, it is useful to perform the division by 100 by changing the attribute calculation.
The following steps demonstrate how to change the default calculation function from Sum
to Average for the column life_expectancy
. We imported the data from
the file ca-graduation-rates.csv, and created a dataset CA
College Readiness. See how to do this in Importing Data from Flat Files
and in Creating Datasets from Imported
Files.
In the Datasets area, select CA College Readiness (main.ca_graduation_rates)
.
In the Dataset Detail menu, select Attributes.
In the Attributes area, select Edit Attributes.
Under Measures, find the field percentage_of_grads..-
, and click the (clone) icon next to it.
Under Measures, find the new cloned field Copy of percentage_...
, and click it.
The Column View window modal appears.
In the Column View modal, make the following changes:
percentage_grads_with_college_required_courses
.Average
.[percentage_of_grads_with_uc_or_csu_required_courses]/100
.Click Apply.
Under Dataset: CA College Readiness, click Save.
As a result of the change, the new column uses reports the percentage as a decimal, so that %
display format can be applied correctly.
To test this, click New Visual in the top left corner of the Dataset: CA College Readiness page.
Populate the shelves from the available fields (Dimensions, Measures, and so on) listed in the left navigation menu.
county
, gender
, and ethnicity
, and place them on the Dimensions shelf.total_grads
, percentage_of_grads_with_uc_or_csu_required_courses
, and percentage_of_grads_with_college_required_courses
, and place them on the Measures shelf.percentage_of_grads_with_uc_or_csu_required_courses
, or bad%
In the Display Format modal window,
Under Decimal Places, enter 2.
To see all decimal places, select All.
As you can see, the percentage reported is inaccurate. In fact, it is 100 times greater than it should be.
percentage_of_grads_with_college_required_courses
, or % ready for college
.As you can see, this formatted field reports the value accurately.