Calculated attributes are attributes which are derived from other attributes based on a formula. A formula is a collection of one to many functions applied on one to many attributes.
Calculated attribute formulas are entered in the formula area (WPAS 4.6) of attribute editor after selecting "calculated" from the attribute type list. You can use existing attributes or
calculated attributes in your formulas.
When creating a formula it is always a good practice to think what you need to be calculated and the required input from user to produce the result. Calculated Attribute Functions page provides the list of functions available for
calculations.
For example, the following formula calculates net present value (NPV) of an investment based on a discount rate.
NPV(!#ent_npv_discount_rate#, !#ent_npv_year_1_cashflow#,
!#ent_npv_year_2_cashflow#, !#ent_npv_year_3_cashflow#, !#ent_npv_year_4_cashflow#, !#ent_npv_year_5_cashflow#)+ !#ent_npv_initial_investment#
To be able to create this formula, we need to provide parameters defined in function parameter definition: NPV(discount_rate, value1, [value2, ... value_n])
Based on the NPV function parameters, we need:
- Initial Investment (decimal)
- Annual discount rate (decimal)
- The returns in every year starting from the first year
In the example, we calculated the NPV value in for a 5 year term, so we added 5 additional decimal text attributes, each one representing the cash flow of the corresponding year.
Once defined calculated attributes are no different than other attribute types. Calculated attributes can be used in submit form layouts to provide realtime calculation results or in view layouts
to display precalculated results. When used in form layouts, the form elements containing calculated fields are read only.
All formulas used in the calculated attributes are hidden from users to protect sensitive formulas from public eye. Calculations are processed in the server-side and then displayed to users. If
you need to show your formulas, you can provide the formula on your page containing the view or form shorcode.
For additional examples, check out Microsoft's page for Excel functions.