You need to sign in to do that
Don't have an account?
Formulas: Raising a number to a power with a fractional exponent
We have some sophisticated math in our configuration/pricing system, which includes formulas in which (arbitrary) numbers need to be raised to (arbitrary) fractional powers. For example, a^2.3879 or b^6.912358. After debugging our pages when they simply didn't work (the formulas had to be set up as Workflow field updates), I determined (and then found an online reference to) the fact that Salesforce only allows positive, integer exponents.
Is there some way around this? I cannot imagine I'm the first person to encounter this issue. Some math library I could add to the system? Or workaround? Any advice is very much appreciated.
Well the work around is to change your math a little bit.
b^(-6.912358) = 1 / (b^6.912358)
"Salesforce only allows positive, integer exponents."
I agree. This should be standard salesforce functionality. A $5 calculator can handle fractional exponents.
I actually do have a way to get around this until Salesforce provides native support. Although Salesforce currently only accepts positive, integer values as exponents the EXP function and LN function accept any number, including decimal values. Using a little math you can rearrange the problem-see the example below:
a = b^(c)
ln(a) = c * ln(b)
a = e ^ [ c * ln(b) ]
Rearranging the problem into this format allows you to utilize the EXP and LN functions, which as mentioned before, can accept decimals and negative values alike.
Adjusted Quantity formula field on Quote Line object where my exponent is 0.59 and I want to use an adjusted quantity which will be used to calculate Net Price.
Fail:
Adjusted Quantity (Number) =
SBQQ__Quantity__c ^ 0.59
Success:
Adjusted Quantity (Number) =
EXP(0.59 * LN( SBQQ__Quantity__c ))