I have two fields on Opportunity: FieldA and FieldB. FieldA is a formula field of type Currency with 2 decimal places. FieldB is a currency field also with two decimal places. Let's assume the value of FieldA is 291.73 and the value of FieldB is 291.73.

When I subtract FieldA from FieldB in a formula field called BookingsAmountCompare, which has the return type of Number, it gives the value 0.01 instead of 0. How can I handle this issue?

enter image description here

enter image description here

3 Answers 3


Try this: IF(FieldA = FieldB, 0, FieldA - FieldB)

  • Hi fred, I am using the formula field BookingsAmountCompare in a query to fetch all the records where the value is not equal to 0. I tried your approach but still no changes, the BookingsAmountCompare is still showing the value 0.01. Commented Jun 21, 2023 at 11:54
  • Where are you checking this? Have you checked the value of the field in Salesforce?
    – fred
    Commented Jun 21, 2023 at 12:29
  • In a batch class, String query = 'SELECT Id, FieldA, FieldB FROM Opportunity WHERE FieldB != null AND BookingsAmountCompare__c!=0' Based on the retrieved records I am updating the value of FieldA with the value of FieldB. This is from a use-case I am working on. Commented Jun 21, 2023 at 13:36
  • If you check the field in the Salesforce UI does it show as 0 or 0.01?
    – fred
    Commented Jun 21, 2023 at 13:45
  • In the UI it shows 0.01 Commented Jun 22, 2023 at 10:03

Tried to replicate your use case, the issue is not occurring.

  1. Try to use BookingsAmountCompare's return type as Currency having 2 decimal places. If it doesn't work try below formula for BookingsAmountCompare.
  2. Try formula IF( FieldA = FieldB , 0.00, FieldA - FieldB)

Salesforce internally stores higher precision than what the UI is configured to show. However, it will round to the nearest significant display digit when the value is displayed. In other words, even though the UI shows 228019.67 in each field, it is entirely possible that the fields might be slightly off, anywhere from 228019.66500 to 228019.67499 (approximately). If you have these values, when you subtract, you'd get 0.00999, which the UI would then round to 0.01. To make the formula work correctly, use ROUND:

ROUND(FieldA, 2) - ROUND(FieldB, 2)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .