use exponential functions in ui-only field to the power of

I’d like to be able to use “to the power of” exponential functions in a UI-only field. Use case is estimating a payment amount on the front end of a public site. We have a formula field to do this, but the formula is blank until the record is saved, I’d like to show the calculation before saving. But it requires, in particular, this formula: “(1+ MonthlyInterest__c ) ^ NoofPayments2__c”, where the ^ symbol represents “to the power of”.

Would be great to see that as an option in the UI-only dropdown list of Operators.

In the mean time, any way to hack this?

You could build a quick custom field renderer in javascript and use Math.pow().

@jacksanford Hi, not sure if you ever succeeded in accomplishing this above. As i have now a very similar requirement and need to use EXP excel function. if you did and could share the way you did it, or JS you used (if any) that would be amazing!

Let me know

Thx

Hi @Dave, no I never did figure that out. Matt’s suggestion above is where I would start, create a snippet that fires whenever a given field is changed that updates the value using math.pow()

Ok perfect thank you for quick answer :slight_smile:

You can define a custom function and use that function in UI formula:

https://docs.skuid.com/latest/en/skuid/api/skuid_formula.html

expanding on @Skuidward_Tentacles idea. Custom formulas are great for user cases like this one. Create a new custom formula and paste this into there.

new skuid.formula.FormulaFunction (
  'powerOf',
  function (base, exponent) {
    return Math.pow(base, exponent);
    },
{
    namespace: 'test',
    numArgs : 2,
    returnType : 'number'
  }
);

To call this function in an UI-Only formula use:

test__powerOf((1+{{MonthlyInterest__c}}), {{NoofPayments2__c}})