0

Is it possible to use visualforce page to create a month by month revenue allocation using a start date, end date and total revenue. If so, how would I acheive something like this. I have been struggling with this for a while, so any help would be greatly appreciated. I would then like to use the visualforce for the report to display on the dashboard.

I am trying to create a report that shows revenue allocation month by month for all accounts. The start and end date is on the account along with the total revenue (rolled up from the opportunity). I cannot simply create a report that would do this via salesforce report. I.E. Account could be from 04/23/2014 to 05/15/2015. How would I show month by month revenue allocation for this?

  • 3
    Can you elaborate on what you're trying to achieve? Is this question more about how do you show this in a report, rather than specifically whether it can be done as a visualforce page? (i.e. you've assumed it can only be done in visualforce and are therefore asking about visualforce?) What object are you working with? are the start/end dates and total revenue changing over time? (i.e. are you looking for a snapshot each month to see what they were at a given point in time) Is this a similar report to showing the opportunity pipeline over time? – Nick Cook Jun 5 '15 at 1:26
0

Let me first say that what you're asking about could indeed be done with a custom report and will work much better for you as one because a full VisualForce page can't be added to your standard dashboard as a table. You can only display 10 records on a table at a time in a dashboard table which I'd expect to apply to a visualforce charted table as well (not certain if you'd be able to display the grand total either, would need to test that). A VisualForce Dashboard element can be created, but there's a limitation in that it won't be visible if you send it to someone via email distribution.

As VisualForce, generically speaking, what you'll need to do is create a custom controller for your "Revenue Report" on Opportunity. The class would be an extension of Opportunity that would also enclose the results in a wrapper. Your controller would begin by getting the start and end dates from your page then run a query that's grouped by each time period you want to use and put the results into a "wrapper class".

You'd then output those results in a table on a VisualForce Page using an <Apex: repeat> tag. The html for the page would look something like this:

<apex:page standardController="Opportunity" extensions="MYCustomController" standardStylesheets="false">

<apex:stylesheet value="{! URLFOR($Resource.MyCustomStyleSheet.css')}"/>
// add any custom styling here

<table>
  <tr>
  <td>Start Date</td>
  <td>End Date</td>
  <td>Account Name</td>
  <td>Opp Amount</td>
  <apex:repeat> value="{!wrapper}" var="w">
    <apex:repeat value="{!w.OLst}" var="o">
    <tr>
    <td>{!o.StartDate}<td>
    <td>{!o.StartDate}<td>
    <td>{!o.Account.Name}</td>
    <td>{!o.Opportunity.Amount}</td>
    </tr>
    </apex:repeat>
    <tr>
    <td>{!w.StartDate}<td>
    <td>{!w.StartDate}<td>
    <td> </td>
    <td>Grand Total: <apex:outputText value="${0,number,0.00}"><apex:param value="{!w.GT}"/></apex:outputText>
    </tr> 
  </apex:repeat>
</table>
</apex:page>

With the above, you could potentially have multiple start and end dates if chose to, causing the table to get longer with each period rather than wider. This should give you a good starting point. Your query would also want to roll-up any opportunities for the period on each account if you don't want to need to group and sum them (a pita if you do).

I recommend the following resources to learn more: Visualforce Workbook and the Visualforce Developer’s Guide.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.