I`m using below Outputtext to show negative values in brackets. For example, -1,000.00 to reflect as (1,000.00)

<td>$<apex:outputText value="{0, Number, Currency}">   <apex:param value="{!target}" /> </apex:outputText></td>

Above line works fine except that I want to get rid of decimals. Negative value should appear like this (1,000) without decimals. Can someone please suggest a better way to achieve this? Can I achieve this using LEFT or Right Funtion?


You can specify your own number format. If you want to avoid decimals, it should look like:

<apex:outputText value="{0, Number, ###,##0}">

As for the brackets, you can add formulas for that:

<apex:outputText value="{!IF(target < 0, '(', '')}{0, Number, ###,##0}{!IF(target < 0, ')', '')}">

Or it might be easier to read if you split them out:

<apex:outputText value="{!IF(target < 0, '(', '')}" />
<apex:outputText value="{0, Number, ###,##0}">
    <apex:param value="{!target}" />
<apex:outputText value="{!IF(-1000 < 0, ')', '')}" />
| improve this answer | |

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