You need to sign in to do that
Don't have an account?
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.
Controller:
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;
}
}
Page:
<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}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Any help is most appreciated. Thanks!
Something similar just got answered here:
Visualforce&thread.id=13957
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:column>
<apex:facet name="header">
<apex:outputText value="Percentage" />
</apex:facet>
<c:MathWidget val1="{!f.Number_1__c}" val2="{!f.Number_2__c}" />
</apex:column>
...
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}" />
</apex:component>
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?
Thanks,
S.Sivakumar