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

Controller Help on Calculating Percentage

Another newbie question here.  I have created a page using the revenue forecast object that lists the forecast owner/start date/quota/closed


I'd like to add one more column after closed that shows the percentage of quota achieved.  There is no field on the Revenue Forecast object to pull this from, nor can  I add it as a custom field.  I'm pretty sure this can be calculated with a controller extention, but the few attempts I have made have not resulted in anything.





public class retrieveQuota{
private List<Schema.RevenueForecast> revenueforecast;
public List<Schema.RevenueForecast> getRevenueForecast()

revenueforecast = [Select Closed,Pipeline,OpportunityRollupPipeline,OwnerId,Quota,StartDate
from RevenueForecast where StartDate>=2009-01-01 AND Quota<>NULL Order By OwnerId];

return revenueforecast;





<apex:page controller="retrieveQuota" tabStyle="Opportunity">
<apex:pageBlock title="List">

<apex:pageBlockTable value="{!RevenueForecast}" var="f">
<apex:column value="{!f.OwnerId}"/>
<apex:column value="{!f.StartDate}"/>
<apex:column value="{!f.Quota}"/>
<apex:column value="{!f.Closed}"/>



 Any help is most appreciated.  Thanks!




Something similar just got answered here:



I played around a little with it and found I could supply 2 number fields to a component and get a percentage back:


In your visualforce page add a new column for your percentage to your table




<apex:facet name="header">
<apex:outputText value="Percentage" />

<c:MathWidget val1="{!f.Number_1__c}" val2="{!f.Number_2__c}" />




Create a Component (MathWidget in my case)


<apex:component controller="MyWidgetController" access="global">
<apex:attribute type="double" name="val1" description="val1" assignTo="{!myVal1}" />
<apex:attribute type="double" name="val2" description="val2" assignTo="{!myVal2}" />
<apex:outputText value="{!myPercent}" />

 And another controller apex class to go with it:


public class MyWidgetController {

private double myVal1;
private double myVal2;

public MyWidgetController() {

public double getMyPercent() {
return (myVal1 * 100 / myVal2);

public double getMyVal1() {
return myVal1;
public void setMyVal1(double d) {
myVal1 = d;

public double getMyVal2() {
return myVal2;
public void setMyVal2(double d) {
myVal2 = d;


Hope it helps.








Hey i am not able to use this object. i am getting following error


Error: sObject type 'RevenueForecast' is not supported.


Can you help me in this issue?