I have requirement to display aggregate result values in visualforce page and it should be formatted to currency. Could anyone help me with this issue i am facing.

apex controller:

RepSalesbyFund = Database.query('SELECT sum(Twelve_Month_Purchase__c) Twelve_Month_Purchase__c FROM RepSalesByFund__c where Rep_GroupID__c in :searchedConIds order by ' + sortFullExp + ' NULLS LAST limit 1000');

Visualforce page:

     <apex:column value="{!a['Twelve_Month_Purchase__c']}"  style="Color:{!IF(a['Twelve_Month_Purchase__c'] < 0,'red', 'blue')}">
     <apex:facet name="header">  
       <apex:commandLink action="{!rsbfViewData}" value="12 Mos Purch{!IF(a['Twelve_Month_Purchase__c'],IF(rsbfsortDirection='ASC','▼','▲'),'')}" reRender="rsbfpageBlock">
         <apex:param value="SUM(Twelve_Month_Purchase__c)" name="column" assignTo="{!rsbfsortExpression}" ></apex:param>

You can format the value to diaplay as currency like this:

<apex:outputText value="$&nbsp{0, number, 000,000.00}">
<apex:param value="{!a['Twelve_Month_Purchase__c']}" />

Please let me know if this helps

  • Couldn't you just include it in the format string itself? – Adrian Larson Jul 18 '16 at 19:51
  • Thanks ..Actually it works. It just tweaked a bit. <apex:outputText value="{0, number, currency}"> <apex:param value="{!a['Twelve_Month_Purchase__c']}" /> </apex:outputText> – Dinesh Jul 18 '16 at 20:48

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.