1

This question already has an answer here:

I have this visualforce tag

<td align="center">{!IF(relatedTo.Total_Professional_Services_Before_Disc__c=0, "--", "$" + TEXT(ROUND(relatedTo.Total_Professional_Services_Before_Disc__c,0)))}</td> 

and the idea is that if it is 0, it will output '--' else the number in US currency format. It works fine but let's say the number is 9999, it will output

$9999

Is there a simple way to make it output

$9,999

without creating a controller as this is just in a simple visualforce email template?

Edit: Thank you to those that answered. Final solution came out to be

<td align="center">
  <apex:outputText value="${0, number, ###,##0}" rendered="{!IF(relatedTo.Total_Professional_Services_Before_Disc__c=0, false, true)}">
    <apex:param value="{!relatedTo.Total_Professional_Services_Before_Disc__c}"/>
  </apex:outputText>
  <apex:outputText rendered="{!IF(relatedTo.Total_Professional_Services_Before_Disc__c=0, true, false)}">--</apex:outputText>
</td>

It isn't pretty and I can't say I'm excited to replace 28 tags in a table like this, but it works

marked as duplicate by David Reed, glls, Pranay Jaiswal, Derek F, Reshma Mar 8 at 7:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

You could use outputText to print a formatted number with rendered attribute to define whether to print the number or the double dash (--).

<apex:outputText value="{0, number, ###,##0}">
    <apex:param value="{!myNumber}"/>
</apex:outputText>
  • Using this method, how would you add the '$' – adam Mar 7 at 16:24
  • Just place value="${0, number, ###,##0}". – Dahn Mar 14 at 9:14
1

with $ sign ...

<apex:outputText value="${0, number, ###,##0}">
    <apex:param value="{!myNumber}"/>
</apex:outputText>

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