function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Client ServicesClient Services 

Create Google Table Using Analytics API

Hi All--

I'm new to Salesforce and am trying to build a VF page that will display 25 records and 5 Columns using the analytics api. I have gotten the following code to properly display the 25 records, however it only displays 2 columns (Property Name and Record Count). I have tried building the underlying report in matrix, summary, and tabular format...each with the same result. I believe there is something in the code that is limiting the display to 2 columns, but I can't figure it out. The columns I need displayed are all custom. 

Thanks in advance for your help! You don't know how amazing it will be if I get this down :)

<apex:page sidebar="false" showHeader="false">
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" />
    <apex:includeScript value="https://www.google.com/jsapi" />
    <script>
        google.load('visualization', '1', {
            'packages': ['table']
        });
        $(document).ready(function () {
            $.ajax('/services/data/v29.0/analytics/reports/{!$CurrentPage.parameters.reportId}', {
                beforeSend: function (xhr) {
                    xhr.setRequestHeader('Authorization', 'Bearer {!$Api.Session_ID}');
                },
                success: function (reportResult) {
                    var chartPoints = [];
                    $.each(reportResult.groupingsDown.groupings, function (index, value) {
                        chartPoints.push([value.label, reportResult.factMap[value.key + "!T"].aggregates[0].value]);
                    });
                    var options = {};
                    var labels = [
                        [
                        reportResult.reportExtendedMetadata.groupingColumnInfo[reportResult.reportMetadata.groupingsDown[0].name].label,
                        reportResult.reportExtendedMetadata.aggregateColumnInfo[reportResult.reportMetadata.aggregates[0]].label
                        ]
                    ];
                    var myData = google.visualization.arrayToDataTable(labels.concat(chartPoints));
                    var table = new google.visualization.Table(document.getElementById('table'));
                    table.draw(myData, {showRowNumber: false});
                }
            });
        });
    </script>
    <div id="table" style="height: 400px;width:400px;"></div>
</apex:page>
Doug KellsDoug Kells
Hi, I'm wondering if you ever found a solution to this issue and creating a google table using the Analytics API.

I find myself stuck in almost exactly the same spot and haven't found any similar postings with a solution.