I'm working on the npm Downloads Counter connecter using this Google Data Studio codelabs. In the getFields() function i created two dimensions( 'day' and 'packageName') and one metric(downloads). But in Data Studio, all fields appear as dimensions, there is no metric.
getFields() function
function getFields() {
var fields = cc.getFields();
var types = cc.FieldType;
var aggregations = cc.AggregationType;
fields
.newDimension()
.setId('packageName')
.setName('Package')
.setType(types.TEXT);
fields
.newDimension()
.setId('day')
.setName('Date')
.setType(types.YEAR_MONTH_DAY);
fields
.newMetric()
.setId('downloads')
.setName('Downloads')
.setType(types.NUMBER)
.setAggregation(aggregations.SUM);
return fields;
}
"Green" Number fields are currently the expected output (thus, in this case, the Downloads
Number field displayed as a "Green" Dimension is the expected behaviour) and was part of the 31 Oct 2019 Update to Google Data Studio, which "Improved data modeling in Data Sources".
"Blue" Metric fields would be values that are pre-aggregated, such as the Metrics in the Google Analytics Data Source or creating an Aggregated Calculated Field in your respective Data Source such as SUM(Downloads)
which would be displayed as a "Blue" Metric.
To elaborate on the update, adding a section from the release notes:
You don't need to take any action. Charts and calculated fields used in your reports will work as before the upgrade. However, if you create or edit data sources from flexible schema (or tabular) data sets, such as Sheets or BigQuery, you may notice that number fields that previously appeared as metrics (blue fields) with an aggregation of None now appear as green dimensions with a new Default Aggregation of Sum. This change has no effect in existing charts, but makes it easier to use these fields in more flexible ways.