Let's say I have an object 'Vegetables'. It has 3 fields. Name, Amount, Month.

So for each Month we have a record of the amount of each type of vegetable sold.

How would I go about displaying this in a format where the first column is the Name, then the columns to the right are the Month's totals.

Something like this:


I was thinking I had to use an aggregate but I'm not sure I can write one that ends up with the data in the correct structure. I'll probably use a Map> for the data.

The other problem I can't seem to figure out is the VF markup.

I would guess this is a fairly common problem. How is the best way to solve it?




1 Answer 1


If the information is already in Salesforce couldn't you create a report and group the items using summary option and then show it as visualforce with the following code:

<apex:page >
  <apex:iframe src="/enterreportidhere"/>  

Put the id of your report where it says enterreportidhere in the code above. Also please take a look at the Visualforce Workbook as one of the comments mentioned. Typically users on this forum will vote your question down if you do not post the code that you have tried. The Visualforce Workbook is very helpful.

  • I think this is going to eventually be the solution. I thought about posting my code but I have about 3 different things on the VF page that I've tried. I was hoping someone could point me in a direction of a solution. I was thinking that this had to be a fairly frequent request from users that there would be a fairly straightforward solution by now. Jenny B had a great suggestion that might work. But I think the report is probably the best answer (and one I didn't even think of).
    – LeeFranke
    Commented May 22, 2015 at 22:17
  • @LeeFranke when I first started using this forum I felt the same way. I needed a quick solution and I wasn't asking for code I just wanted to be pointed in the right direction, but that did not go over well in this forum. Sometimes now I will post 3 or 4 things I tried just because that way someone won't send you something you already tried or try to vote your question down. I'm glad my answer could be a bit of help to you. I wish you the best of luck on this. Commented May 23, 2015 at 3:50
  • I actually opened a ticket with SFDC regarding this. They confirmed the only way to display the data in this format was to create a report. They did send me an example on how to run the report when the VF page fires.peterknolle.com/…
    – LeeFranke
    Commented May 27, 2015 at 19:20

You must log in to answer this question.

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