You need to sign in to do that
Don't have an account?

Using AggregateResult & GROUP BY ROLLUP- "Total" row returned at top instead of bottom
Good Evening,
I am using AggregateResult and GROUP BY ROLLUP to output some data. After a long slog, I've got it working the way I need it to... except for one thing. The "Total" row is showing at the top of the list instead of the bottom when I put the data into a table.
Would anybody be able to help me get my total row so that it is the last item in the table?
Here is my VF page:
And here is my controller:
I am using AggregateResult and GROUP BY ROLLUP to output some data. After a long slog, I've got it working the way I need it to... except for one thing. The "Total" row is showing at the top of the list instead of the bottom when I put the data into a table.
Would anybody be able to help me get my total row so that it is the last item in the table?
Here is my VF page:
<apex:page controller="CurrentWeekDY"> <apex:pageBlock title="Delivery WTD"> <apex:pageBlockTable value="{!DelSumOut}" var="dy"> <apex:column value="{!dy.Campaign}" headerValue="Campaign" /> <apex:column value="{!dy.Delivery}" headerValue="Delivery" /> </apex:pageBlockTable> </apex:pageBlock>
And here is my controller:
public class CurrentWeekDY { public class DelSum { public String Campaign {get; set;} public String Delivery {get; set;} public DelSum(string c, string d) { this.Campaign = c; this.Delivery = d; } } public List<DelSum> DelSumList = new List<DelSum>(); public List<DelSum> getDelSumOut() { AggregateResult[] AgR = [SELECT Camp__c, SUM(Spend__c) FROM TL_Client__c WHERE CWDelivery__c = TRUE GROUP BY ROLLUP(Camp__c) ORDER BY Camp__c]; for (AggregateResult DYList : AgR) { DelSumList.add(new DelSum(String.valueOf(DYList.get('Camp__c')), String.valueOf(DYList.get('expr0')))); } return DelSumList; } }
I would really appreciate any help!!
Thanks,
John

on your page you are just displaying a list object. Not sure how Total field is even appearing on top of your table. I dont see any tag to show total.

thanks Rick, unfortunately I'm still stuck with the total at the top
It is because your method getDelSumOut(), and you are use it as variable on pageBlockTable. Try to declare delSumList on constructor and change pageBlockTable variable to delSumList instead of delSumOut. Let me know if the total still on the top.

Thatnks for your help Rick, I changed the constructor to delSumList and am still getting the total on the top! Do I need to flip the order of my strings?