• Mildred Morales 19
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
HALF EVEN Rounding Formula
I need to use a something called Bankers Rounding in several formulas field in salesforce. This method is also called HALF EVEN. The only thing I can find is using APEX but I am wodering if anyone has been able to apply this using the standard formula screen. Here is the description

Rounds towards the “nearest neighbor” unless both neighbors are equidistant, in which case, this mode rounds towards the even neighbor. This rounding mode behaves the same as the HALF_UP rounding mode if the digit to the left of the discarded fraction (decimal point) is odd. It behaves the same as the HALF_DOWN rounding method if it is even. For example:
Input number 5.5: HALF_EVEN round mode result: 6
Input number 1.1: HALF_EVEN round mode result: 1
Input number -1.1: HALF_EVEN round mode result: -1
Input number -2.7: HALF_EVEN round mode result: -3

1 Decimal[] example = new Decimal[]{5.5, 1.1, -1.1, -2.7};
2 Long[] expected = new Long[]{6, 1, -1, -3};
3 for(integer x = 0; x < example.size(); x++){
4    System.assertEquals(expected[x],
5        example[x].round(System.RoundingMode.HALF_EVEN));
6}
Note that this rounding mode statistically minimizes cumulative error when applied repeatedly over a sequence of calculations.
Hi all! 

I am trying to replicate the excel Days360 function which returns the number of days between 2 dates, based on a 360-day year (12 x 30 months).

Does anyone know how to accomplish this?
HALF EVEN Rounding Formula
I need to use a something called Bankers Rounding in several formulas field in salesforce. This method is also called HALF EVEN. The only thing I can find is using APEX but I am wodering if anyone has been able to apply this using the standard formula screen. Here is the description

Rounds towards the “nearest neighbor” unless both neighbors are equidistant, in which case, this mode rounds towards the even neighbor. This rounding mode behaves the same as the HALF_UP rounding mode if the digit to the left of the discarded fraction (decimal point) is odd. It behaves the same as the HALF_DOWN rounding method if it is even. For example:
Input number 5.5: HALF_EVEN round mode result: 6
Input number 1.1: HALF_EVEN round mode result: 1
Input number -1.1: HALF_EVEN round mode result: -1
Input number -2.7: HALF_EVEN round mode result: -3

1 Decimal[] example = new Decimal[]{5.5, 1.1, -1.1, -2.7};
2 Long[] expected = new Long[]{6, 1, -1, -3};
3 for(integer x = 0; x < example.size(); x++){
4    System.assertEquals(expected[x],
5        example[x].round(System.RoundingMode.HALF_EVEN));
6}
Note that this rounding mode statistically minimizes cumulative error when applied repeatedly over a sequence of calculations.
Hi all! 

I am trying to replicate the excel Days360 function which returns the number of days between 2 dates, based on a 360-day year (12 x 30 months).

Does anyone know how to accomplish this?
Hi I was hoping someone would be able to give me a little advice or point me in the right direction if the information is already documented somewhere. Im looking to build some functionality onto an object where the quantity of a quantity field would define the quantity of records to create. Similar to how payment schedule works on products. So if I specified 10 in quantity box it would create 10 related object records.