How to Create a Formula with List of Options Attributes (Multiple Selection)

This topic explains how to write a formula containing multiple-selection List of Options attributes.

For example, consider the following form (see figure below), in which certain data is used to calculate the risk index for a car insurance. In this case, the more safety items that are available in the vehicle (Safety Items in the Vehicle field) and the longer the time that drivers have their license (Driver's License Issued in the Last field), the lower the risk index will be (Insurance Risk Index field). The maximum value for this index is 1,000, which will decrease according to the options selected in the two previous fields.

 

 

In the example above, the formula obeys the following rules:

    For each option selected in the Safety Items in the Vehicle field, the Insurance Risk Index field will be decreased by 5%.

    For the options in the Driver's License Issued in the Last field, only the worst case item (highest risk) will be considered. For example, in the figure above, only the 3-5 years option will be considered, since it holds a higher risk than the other option selected, 5-10 years. To reach this conclusion, the formula analyses the following terms sequentially:

o If the 0-1 year and 1-3 years options are selected, the risk index will not decrease.

o If the previous condition is not met and the 3-5 years option is selected, then the risk index will be decreased by 5%.

o If the previous conditions are not met and the 5-10 years option is selected, then the risk index will be decreased by 10%.

o If the previous conditions are not met and the Over 10 years option is selected, then the risk index will be decreased by 15%.    

 

The above conditions are configured in the formula through the Contains() function, which verifies which options are selected, as in the example below.

#optionsSeleced=0;

#optionsSeleced=#optionsSeleced+(@safetyitems.Contains('Anti Theft-Alarm') ? 1 : 0);

#optionsSeleced=#optionsSeleced+(@safetyitems.Contains('Coded Key') ?1 :0 );

#optionsSeleced=#optionsSeleced+(@safetyitems.Contains('GPS Device') ?1 : 0);

#optionsSeleced=#optionsSeleced+(@safetyitems.Contains('Remote Access') ? 1 : 0);

 

#SafetyItemsReduction=1-#optionsSeleced*0.05;

 

#DriverLicenseReduction=((@dlissuedinlast.Contains('0-1 year')) ? 1 : 

                     (@dlissuedinlast.Contains('1-3 years')) ? 1 :     

                     (@dlissuedinlast.Contains('3-5 years')) ? 0.95 :

                     (@dlissuedinlast.Contains('5-10 years')) ? 0.90 :

                     (@dlissuedinlast.Contains('Over 10 years')) ? 0.85 : 1);

 

# RiskIndex = 1000 * #SafetyItemsReduction * #DriverLicenseReduction;

 

#RiskIndex