In this post we will see how we can write Excel FISHER function in Apex Salesforce. Before going to the apex code lets first see some details about FISHER function. This function returns the fisher transformation at x.

**Syntax of FISHER function is as follows in Excel**

- FISHER(x)
- WHERE x is required
- Value of x should be greater than -1 and less than 1 i.e -1 < x < 1.

Now see the code for Excel FISHER function in Apex Salesforce.

1 2 3 4 5 6 7 8 9 10 11 12 |
/** * @author : 799 The Coder * @date : 21 Aug 2017 * @description : This method returns Fisher transformation at x, equivalent to FISHER(x) excel function * @param : Decimal x (-1 < x < 1) * @return : Decimal (fisher) */ public static Decimal fisher(Decimal x) { Decimal fisher = 0.0; fisher = (Math.log((1 + x) / (1 - x))) / 2; return fisher; } |

Above code can be added in any apex class, after adding this code we can use it as per our requirement. Lets test it from developer console. Go to developer console and in Execute anonymous window paste the below code.

1 2 3 4 |
Decimal x = 0.75; Decimal fisher = ExcelFormulaUtils.fisher(x); // Use your class name instead of ExcelFormulaUtils in above statement. System.debug('####> fihser = ' + fisher); |

After executing above code snippet you will get below output.

Hope this code will save your time, if you need to implement FISHER function in salesforce.

Happy Coding 🙂

799 The Coder

See some more post for Excel function in Apex