Skip to main content
John Barry (Cornell University) a posé une question dans #Formulas

We have a Flow with a formula that looks at a Discount Code object and pulls in any relevant Discount Percentage or Discount Amount.  The Discount Percentage part of the formula works perfect.  The Discount Amount, although it is set as a Currency field (16,2) with 2 decimal places, returns many more decimal places.  As an alternative solution, I tried to create  a Discount_Amount_Number__c Number field that referenced the Discount_Amount__c currency field in the formula, but that is throwing an unhandled exception in the Flow.

 

Here are two formulas I've tried.  What am I doing wrong or what can I do/change to just turn the value of the Discount Amount in the Flow formula?

 

IF(

    NOT(ISBLANK({!Get_Discount_Codes_with_Discount_Percentage.Discount_Amount__c})), 

    {!Get_Discount_Codes_with_Discount_Percentage.Discount_Amount__c}, 

    IF(

        NOT(ISBLANK({!Get_Discount_Codes_with_Discount_Percentage.Discount_Percent__c})),  

        {!Get_EventClass_Records.Course__r.Course_Fee__c} * ({!Get_Discount_Codes_with_Discount_Percentage.Discount_Percent__c} / 100),  

        0 

    )

)

 

ROUND(

   IF(

      NOT(ISBLANK({!Get_Discount_Codes_with_Discount_Percentage.Discount_Amount__c})), 

      {!Get_Discount_Codes_with_Discount_Percentage.Discount_Amount__c}, 

      IF(

         NOT(ISBLANK({!Get_Discount_Codes_with_Discount_Percentage.Discount_Percent__c})),  

         {!Get_EventClass_Records.Course__r.Course_Fee__c} * ({!Get_Discount_Codes_with_Discount_Percentage.Discount_Percent__c} / 100),  

         0 

      )

   ), 

   2

)

Thanks for you help.

John

Currency Formula in Flow - too many Decimal places

 

discountamount.PNGdiscount amount screenshot.PNG

 

 

#Formulas

1 réponse
  1. 20 sept., 06:42

    Hi John, the ROUND(..., 2) approach is correct for limiting the calculated result to 2 decimal places. 

    One thing to check is the data type of the Flow formula resource. Make sure the formula resource is set to Currency, rather than Number/Text, and that you aren't converting the Currency field to another type elsewhere in the Flow. 

    You can also simplify the formula slightly: 

    ROUND(

    IF(

    NOT(ISBLANK({!Get_Discount_Codes_with_Discount_Percentage.Discount_Amount__c})),

    {!Get_Discount_Codes_with_Discount_Percentage.Discount_Amount__c},

    IF(

    NOT(ISBLANK({!Get_Discount_Codes_with_Discount_Percentage.Discount_Percent__c})),

    {!Get_EventClass_Records.Course__r.Course_Fee__c} *

    ({!Get_Discount_Codes_with_Discount_Percentage.Discount_Percent__c} / 100),

    0

    )

    ),

    2

    )

      

    Also, if the value is displaying as something like 500.00500 despite the underlying Currency field being (16,2), the extra digits may be coming from how the Flow output is being displayed/formatted, rather than from the Currency field itself. 

     

0/9000