1

I am trying to display multiple values in a page which are currency fields set with 2 decimals (in the object).

enter image description here

Currently I am using the below expresion to format the values which works great:

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

The problem that I have is if the value is 10.00 I want to display it as $ 10 and not as $ 10.00

I am guessing I will need to use rendered property but how can I check if the {!number_value__c} has as a decimal 00 ?

1

This is the easiest trick. Multiply the value with 100 and then use MOD function to find the remainder upon diving 100.

Basically, if value is 10.00 then it should be 10.00*100 = 1000, So MOD(1000,100) will give you remainder 0

If value is 10.05 then it should be 10.05*100 = 1005, So MOD(1005,100) will give you remainder greater than 0

This works for me

<apex:outputText value="{0, number,$ ###,###,##0.00}" rendered="{!MOD(number_value__c*100, 100)>0 }">
    <apex:param value="{!number_value__c}" />
</apex:outputText>

<apex:outputText value="{0, number,$ ###,###,##0}" rendered="{!MOD(number_value__c*100, 100)=0}">
    <apex:param value="{!number_value__c}" />
</apex:outputText>
  • Thank you, I ammend {!MOD(bankst.BF010_Month_6__c*100, 100)>0 } to {!MOD(bankst.BF010_Month_6__c*100, 100)!=0 } as I have some negative values – manza Jan 10 '18 at 6:23

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.