Reputation: 131
I am creating a custom visualization in Google Data Studio. I have a single dimension which for example may be city names. Say I have the data below in a google sheet as the data source. The issue I am having is when I get the data from data.tables.DEFAULT any duplicate entries are removed. So in this case I only get 10 results. Ideally I would either want them all including duplicates or I could also live with if a secondary value in the array that is passed with a count of how many there were.
Cities
San Martin
Cincinnati
Tulsa
Vallejo
San Martin
Gastonia
Yucaipa
Tempe
Worcester
Denver
San Martin
Cincinnati
Tulsa
Vallejo
Orlando
Gastonia
Yucaipa
Tempe
Worcester
Denver
San Martin
Cincinnati
let rowData = data.tables.DEFAULT;
console.log(rowData);
When I console log I only have an array of 10 variables.
More information I can't copy array out of console log but it would basically look like this.
[
{barDimension: ["San Martin"]},
{barDimension: ["Cincinnati"]},
{barDimension: ["Tulsa"]},
{barDimension: ["Vallejo"]},
{barDimension: ["Gastonia"]},
{barDimension: ["Yucaipa"]},
{barDimension: ["Tempe"]},
{barDimension: ["Worcester"]},
{barDimension: ["Denver"]},
{barDimension: ["Orlando"]}
]
Here is my manifest file.
{
"data": [
{
"id": "concepts",
"label": "Concepts",
"elements": [
{
"id": "barDimension",
"label": "Dimension",
"type": "DIMENSION",
"options": {
"min": 1,
"max": 1
}
}
]
}
],
"style": [
{
"id": "color",
"label": "Colors",
"elements": [
{
"type": "FONT_COLOR",
"id": "barColor",
"label": "Bar Color",
"defaultValue": "black"
}
]
}
]
}
Upvotes: 0
Views: 3148
Reputation: 151
The behaviour described above is correct: Data Studio returns a distinct set of dimensions in data.tables.DEFAULT
.
If you require a count of these dimensions, you will need to add a metric, like COUNT
in your Data configuration.
This is however, the user needs to do. You can only enable him to do this by supplying a metric field.
Upvotes: 2