3

I'm trying to create a visualforce page that renders a table based on a report with the analytics API. This is the code that I use to print out the aggregation rows:

<apex:repeat value="{!reportResults.factMap[key].aggregates}" var="agg"> <tr class="info"> <td>{!IF(CONTAINS(chiave,'_'),labelGrouping[1].label ,labelGrouping[0].label )}</td> <td style="text-align:right;" colspan="3"> <span style="color:red;">{!agg.label}</span> </td> </tr> </apex:repeat>

This is the report:

enter image description here

But in the aggregation object there are only the value and not the grouping value.

enter image description here

I'm missing something? There are some workaround?

0

1 Answer 1

1

Not a big expert at analytics API, though taking a stab at this :

Ref: http://www.salesforce.com/us/developer/docs/api_analytics/salesforce_analytics_rest_api.pdf

Look at the example response;

When you look at reportresults map it returns :

"reportResult" : {
"attributes" : null,
"allData" : true,
"factMap" : {
"T!T" : {
"aggregates" : [ {
"label" : "USD 67,043,365.50",
"value" : 67043365.50166918337345123291015625
} ]
},
"0!T" : {
"aggregates" : [ {
"label" : "USD 10,083.33",
"value" : 10083.333333333333939663134515285491943359375
} ]
},
"1!T" : {
"aggregates" : [ {
"label" : "USD 25,016,768.67",
"value" : 25016768.670066006481647491455078125
} ]
},
"2!T" : {
"aggregates" : [ {
"label" : "USD 42,016,513.50",
"value" : 42016513.49826984107494354248046875
} ]
}
},
"groupingsAcross" : null,
"groupingsDown" : {
"groupings" : [ {
"groupings" : [ ],
"key" : "0",
"label" : "-",
"value" : null
}, {
"groupings" : [ ],
"key" : "1",
"label" : "Existing Business",
"value" : "Existing Business"
}, {
"groupings" : [ ],
"key" : "2",
"label" : "New Business",
"value" : "New Business"
} ]
},
"hasDetailRows" : false,
.
.
.

When you look at the factmap it returns aggregates which contains only the value and the name of the aggregate result, you cannot find any reference related to the grouping info.

To get the grouping info this is what I did

Take a look at the

groupingsDown

JSON :

groupingsDown" : {
    "groupings" : [ {
    "groupings" : [ ],
    "key" : "0",
    "label" : "-",
    "value" : null
    }, {
    "groupings" : [ ],
    "key" : "1",
    "label" : "Existing Business",
    "value" : "Existing Business"
    }, {
    "groupings" : [ ],
    "key" : "2",
    "label" : "New Business",
    "value" : "New Business"
    } ]
    }

Create your own Map to match grouping label with Factmap data

I used the above apporach on a report in my org :

<apex:repeat value="{!reportResults.GroupingsDown.Groupings}" var="lab">
    Label : {!lab.label} <br/>
    </apex:repeat>

To get individual grouping label use the key

{!reportResults.GroupingsDown.Groupings[0].label}

Report :

enter image description here

VF PAGE : enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .