Class Field

  • A Field object contains data-related information and its properties determine how it's used in Data Studio.

  • You can create a new field usingfields.newDimension() or similar methods.

  • Field objects have methods to get and set various properties like ID, name, description, type, and aggregation.

  • Methods starting withget retrieve the current value of a field property.

  • Methods starting withset modify the value of a field property and return the Field object for chaining.

Field

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

MethodReturn typeBrief description
getAggregation()AggregationTypeReturns theAggregationType of thisField.
getDescription()StringReturns the description of thisField.
getFormula()StringReturns the formula of thisField.
getGroup()StringReturns the group of thisField.
getId()StringReturns the ID of thisField.
getIsReaggregatable()BooleanReturnstrue if this field can be reaggregated,false otherwise.
getName()StringReturns the name of thisField.
getType()FieldTypeReturns theFieldType of thisField.
isDefault()BooleanReturnstrue if thisField is the default metric or dimension.
isDimension()BooleanReturnstrue if this field is a dimension.
isHidden()BooleanReturnstrue if thisField is hidden.
isMetric()BooleanReturnstrue if this field is a metric.
setAggregation(aggregation)FieldSets the aggregation type of thisField.
setDescription(description)FieldSets the description of thisField.
setFormula(formula)FieldSets the formula of thisField.
setGroup(group)FieldSets the group of thisField.
setId(id)FieldSets the ID of thisField.
setIsHidden(isHidden)FieldSets the hidden status of thisField.
setIsReaggregatable(isReaggregatable)FieldSets the reaggregation-permitted status for aField.
setName(name)FieldSets the name of thisField.
setType(type)FieldSets theFieldType of thisField.

Detailed documentation

getAggregation()

Returns theAggregationType of thisField.AggregationType determineshow Data Studio combines similar data into dimensions.

Return

AggregationType — 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

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


getType()

Returns theFieldType of thisField.

Return

FieldType — The type for this field.


isDefault()

Returnstrue if thisField is the default metric or dimension.

Return

Booleantrue if thisField is the default metric or dimension;false otherwise.


isDimension()

Returnstrue if this field is a dimension.

Return

Booleantrue if this field is a dimension; returnsfalse otherwise.


isHidden()

Returnstrue if thisField is hidden. You can use hidden fields in formulas,but not in charts. You cannot hide fields containing formulas.

Return

Booleantrue if thisField is hidden;false otherwise.


isMetric()

Returnstrue if this field is a metric.

Return

Booleantrue if this field is a metric; returnsfalse otherwise.


setAggregation(aggregation)

Sets the aggregation type of thisField.AggregationType determines how DataStudio combines similar data into dimensions. This throws an error if called on a metric.

Parameters

NameTypeDescription
aggregationAggregationTypeThe aggregation type to set.

Return

Field — This builder, for chaining.


setDescription(description)

Sets the description of thisField. Descriptions are short explanations of a field'spurpose.

Parameters

NameTypeDescription
descriptionStringThe description to set.

Return

Field — This builder, for chaining.


setFormula(formula)

Sets the formula of thisField. Formulas define a data transformation that Data Studioruns at query-time.

Parameters

NameTypeDescription
formulaStringThe formula to set.

Return

Field — This builder, for chaining.


setGroup(group)

Sets the group of thisField. Fields collected into a group are presented together inthe Data Studio UI.

Parameters

NameTypeDescription
groupStringThe group to set.

Return

Field — This builder, for chaining.


setId(id)

Sets the ID of thisField. IDs are unique per set of fields and are used in formulas torefer to fields.

Parameters

NameTypeDescription
idStringThe ID to set.

Return

Field — This builder, for chaining.


setIsHidden(isHidden)

Sets the hidden status of thisField. You can use hidden fields in formulas, but not incharts. You cannot hide fields containing formulas.

Parameters

NameTypeDescription
isHiddenBooleanThe hidden status to set.

Return

Field — This builder, for chaining.


setIsReaggregatable(isReaggregatable)

Sets the reaggregation-permitted status for aField. Attempting to set an aggregationtype on a field that can't be reaggregated results in an error.

Parameters

NameTypeDescription
isReaggregatableBooleanThe reaggregation-permitted status to set.

Return

Field — This builder, for chaining.


setName(name)

Sets the name of thisField. Names are shown to the user to distinguish fields.

Parameters

NameTypeDescription
nameStringThe name to set.

Return

Field — This builder, for chaining.


setType(type)

Sets theFieldType of thisField.

Parameters

NameTypeDescription
typeFieldTypeThe type to set.

Return

Field — This builder, for chaining.

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.