Evan Shen
03/17/2023, 8:25 PMuseInsightDataView
hook to get all the relevant data from a table insight, but I’m not seeing how to get aggregate row data out of the results it returns (the footer rows stuff like sum of a measure across all rows of the table).
One thing I noticed is that in the request payload of the afm/execute
calls generated by the hook, resultSpec.totals
is always left empty, whereas when looking at the afm/execute
calls made by the Analyze tool over the same insight it does have values in there. I’ve also tried using <ExecuteInsight>
to similar results.
Is there an easy way to get useInsightDataView
to also fetch these aggregate rows? Currently it’s looking like I will have to make a separate call to the analytical backend to get the insight definition, then create new dimensions from the attribute bucket’s totals
to give to useInsightDataView
. I wanted to make sure that this is the correct path and I’m not missing something that could save some work.
Thanks!Jiri Zajic
03/18/2023, 12:28 AMuseInsightDataView()
. You'll want to investigate a more programmatic approach with backend.workspace().execution()
. Please see https://sdk.gooddata.com/gooddata-ui-apidocs/v8.12.0/docs/sdk-backend-spi.ipreparedexecution.html and https://community.gooddata.com/gooddata-ui-kb-articles-48/dimensions-in-custom-executions-716. The article shows how to add custom dimensions to the execution, and in a similar manner you should be able to add custom totals and other aspects. Hope that helps!Evan Shen
03/20/2023, 3:20 PMuseInsightDataView()
and <ExecuteInsight>
to include grandTotals
data in the response. It is unintuitive that such tools intended for getting everything about an insight aren’t actually returning everything.Ivan Nejezchleb
03/20/2023, 6:42 PMwithDimensions(..._dim_: Array<IDimension | DimensionGenerator>): IPreparedExecution;
method and interface
export interface IDimension {
/**
* List of localIdentifier's of attribute to put in this dimension.
*/
itemIdentifiers: Identifier[];
/**
* List of totals to include in this dimension.
*/
totals?: ITotal[];
}
Totals are defined declaratively as part of dimension def.
This enhanced execution needs enhanced counter part Insight/custom visualization in you app.Evan Shen
03/20/2023, 6:44 PMIvan Nejezchleb
03/20/2023, 6:46 PMEvan Shen
03/20/2023, 6:46 PMEvan Shen
03/20/2023, 6:48 PMIvan Nejezchleb
03/20/2023, 6:49 PMEvan Shen
03/20/2023, 6:50 PMEvan Shen
03/20/2023, 6:55 PM@gooddata/sdk-ui-all@8.11.0
Ivan Nejezchleb
03/20/2023, 7:08 PM{
"data": {
"id": "8fb1fdf5-73de-4f8b-abc8-4865c6939f01",
"type": "visualizationObject",
"attributes": {
"title": "Table with avg total",
"description": "",
"content": {
"buckets": [
{
"items": [
{
"measure": {
"localIdentifier": "726d013e645c4aa6abb9b317c51fc4fd",
"definition": {
"measureDefinition": {
"item": {
"identifier": {
"id": "f_population",
"type": "fact"
}
},
"aggregation": "sum",
"filters": []
}
},
"title": "Sum of Population",
"format": "#,##0.00"
}
}
],
"localIdentifier": "measures"
},
{
"items": [
{
"attribute": {
"localIdentifier": "f41f70c82cad479e841fe0c3f609803c",
"displayForm": {
"identifier": {
"id": "f_city.id.cityname",
"type": "label"
}
}
}
}
],
"localIdentifier": "attribute",
"totals": [
{
"type": "avg",
"measureIdentifier": "726d013e645c4aa6abb9b317c51fc4fd",
"attributeIdentifier": "f41f70c82cad479e841fe0c3f609803c"
}
]
}
],
"filters": [],
"sorts": [
{
"attributeSortItem": {
"attributeIdentifier": "f41f70c82cad479e841fe0c3f609803c",
"direction": "asc"
}
}
],
"properties": {},
"visualizationUrl": "local:table",
"version": "2"
}
},
"meta": {
"origin": {
"originType": "NATIVE",
"originId": "adff2de919ab43849ef91f1c79d33522"
}
}
},
}
And in definition of table’s attribute, you can see also its total defined
"totals": [
{
"type": "avg",
"measureIdentifier": "726d013e645c4aa6abb9b317c51fc4fd",
"attributeIdentifier": "f41f70c82cad479e841fe0c3f609803c"
}
]
This is RAW object, but the same total definition should be accessible also via Gooddata SDK.UI types and abstractions