Duplicate a data source field
Extend the usefulness of a data source by creating new metrics or dimensions based on existing fields. Just duplicate the original field and change the Type and Aggregation.
Use calculated fields to create more complex dimensions or metrics.
Example: Create a new "Count" metric based on the Player dimension.
This example shows a data source for a sports team's roster. You'd like to get a metric for the number of players on the team. The solution: copy the Player dimension and create a Count metric from it.
- Edit your data source.
- Locate the starting field. Mouse over the field name, then click ⋮
- Click Duplicate.
- This will give you a new field called "Copy of fieldname." Click the field name to rename it.
- Click the Type drop-down menu for the new field.
- Select the new data type. For example, select Number to create a numeric metric. To create a new dimension, select one of the other data types.
- If you are creating a new metric, select the Aggregation.
- For example, select Count to create a cumulative total of the number of values in that field.
- You can edit your new metric or dimension by clicking the fx tab.
Create a metric: an example
It's easy to create new metrics in Data Studio. Suppose you have a spreadsheet that tracks sales people and the regions they cover:
|Employee ID||Sales Region|
A simple Google Sheets data source based on this data would look like this:
To find out how many sales people you have in each region, you can create a new metric to count them:
- Hover on Employee ID, then click the context menu
- Select Count Distinct from the popup menu.
This will create a new metric, Count Distinct Employee ID. (You can change this name by clicking the new field.) The new metric can be used in visualizations just as you would any other field.
Click fx at the end of the metric chip to display the formula editor. Learn more about creating calculated fields.