Class Field Stay organized with collections Save and categorize content based on your preferences.
Page Summary
A Field object contains data-related information and its properties determine how it's used in Data Studio.
You can create a new field using
fields.newDimension()or similar methods.Field objects have methods to get and set various properties like ID, name, description, type, and aggregation.
Methods starting with
getretrieve the current value of a field property.Methods starting with
setmodify the value of a field property and return the Field object for chaining.
Contains field-related data. Its properties determine how the field is used in Data Studio.
constcc=DataStudioApp.createCommunityConnector();constfields=cc.getFields();constfield1=fields.newDimension().setId('field1_id').setName('Field 1 ID').setDescription('The first field.').setType(cc.FieldType.YEAR_MONTH).setGroup('DATETIME');
Methods
| Method | Return type | Brief description |
|---|---|---|
get | Aggregation | Returns theAggregation of thisField. |
get | String | Returns the description of thisField. |
get | String | Returns the formula of thisField. |
get | String | Returns the group of thisField. |
get | String | Returns the ID of thisField. |
get | Boolean | Returnstrue if this field can be reaggregated,false otherwise. |
get | String | Returns the name of thisField. |
get | Field | Returns theField of thisField. |
is | Boolean | Returnstrue if thisField is the default metric or dimension. |
is | Boolean | Returnstrue if this field is a dimension. |
is | Boolean | Returnstrue if thisField is hidden. |
is | Boolean | Returnstrue if this field is a metric. |
set | Field | Sets the aggregation type of thisField. |
set | Field | Sets the description of thisField. |
set | Field | Sets the formula of thisField. |
set | Field | Sets the group of thisField. |
set | Field | Sets the ID of thisField. |
set | Field | Sets the hidden status of thisField. |
set | Field | Sets the reaggregation-permitted status for aField. |
set | Field | Sets the name of thisField. |
set | Field | Sets theField of thisField. |
Detailed documentation
getAggregation()
Returns theAggregation of thisField.Aggregation determineshow Data Studio combines similar data into dimensions.
Return
Aggregation — The aggregationType for this field.
getDescription()
Returns the description of thisField. Descriptions are short explanations of a field'spurpose.
Return
String — The description for this field.
getFormula()
Returns the formula of thisField. Formulas define a data transformation that DataStudio runs at query-time.
Return
String — The formula for this field.
getGroup()
Returns the group of thisField. Fields collected into a group are presented togetherin the Data Studio UI.
Return
String — The group for this field.
getId()
Returns the ID of thisField. IDs are unique per set of fields and are used in formulasto refer to fields.
Return
String — The ID for this field.
getIsReaggregatable()
Returnstrue if this field can be reaggregated,false otherwise.
Return
Boolean —true if this field can be reaggregated,false otherwise.
getName()
Returns the name of thisField. Names are shown to the user to distinguish fields.
Return
String — The name for this field.
isDefault()
isDimension()
Returnstrue if this field is a dimension.
Return
Boolean —true if this field is a dimension; returnsfalse otherwise.
isHidden()
isMetric()
Returnstrue if this field is a metric.
Return
Boolean —true if this field is a metric; returnsfalse otherwise.
setAggregation(aggregation)
Sets the aggregation type of thisField.Aggregation determines how DataStudio combines similar data into dimensions. This throws an error if called on a metric.
Parameters
| Name | Type | Description |
|---|---|---|
aggregation | Aggregation | The aggregation type to set. |
Return
Field — This builder, for chaining.
setDescription(description)
setFormula(formula)
setGroup(group)
setId(id)
setIsHidden(isHidden)
setIsReaggregatable(isReaggregatable)
setName(name)
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.