function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alexy1967Alexy1967 

Rounding Percentage

I am trying to round a percentage to 2 decimal places using the ROUND function, however the result returned is to the nearest whole number.

 

Any help would be most appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
Jeremy.NottinghJeremy.Nottingh

I think a Percent-type field actually stores the value as a decimal fraction, rather than what is displayed. In other words, 16.20% is actually being stored as .1620. So your Round function rounds .1620 to 2 digits, which is .16. 

 

Choices:

Change it to round to 4 digits, or

 

multiply up and back down. I.e. 

 

ROUND((Effective_Discount__c * 100), 2)/100

 

 

See which of these you like better.

 

Jeremy

All Answers

Steve :-/Steve :-/

Can you post the formula that you are using? 

Also, what is the datatype and properties of the field that you are using?

Try something like:

 

ROUND(Number,2)

 

 

Alexy1967Alexy1967

sorry, should have included this in the original post:

 

ROUND(Effective_Discount__c ,2)

 

where data type for Effective_Discount__c is Percent (16,2)

Jeremy.NottinghJeremy.Nottingh

I think a Percent-type field actually stores the value as a decimal fraction, rather than what is displayed. In other words, 16.20% is actually being stored as .1620. So your Round function rounds .1620 to 2 digits, which is .16. 

 

Choices:

Change it to round to 4 digits, or

 

multiply up and back down. I.e. 

 

ROUND((Effective_Discount__c * 100), 2)/100

 

 

See which of these you like better.

 

Jeremy

This was selected as the best answer
Alexy1967Alexy1967

Thanks

 

setting to 4 decimal places worked