---
schema_version: "1"
id: ade6bcaad9930b4d5a223a4f4e6575f79fca07caaa45ba7edc65200a7ac78498
title: "Example: Create an Expression Set to Calculate Discounted Membership Fees"
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/example_es_calculate_discounted_fees.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.example_es_calculate_discounted_fees.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: d7fe6d5bb8247367e908adb85db39975fc09efaef6a272a4d4d06ea8a528f662
description: Configure the expression set version to calculate a contact’s age from their birth date, look up the contact’s step count to get the steps-based discount, and return the discounted gym membership fee after subtracting the total discount from the base membership fee.
products:
  - Industry Solutions
  - Cross Cloud
release: "264"
---
# Example: Create an Expression Set to Calculate Discounted Membership Fees

Configure the expression set version to calculate a contact’s age from their birth date, look up the contact’s step count to get the steps-based discount, and return the discounted gym membership fee after subtracting the total discount from the base membership fee.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d24443e38">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d24443e38 ">To create a field alias for the Birthdate field in the Contact object:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d24443e38 ">System Administrator for a Salesforce org with Business Rules Engine</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d24443e38 ">To create the expression set, and design and activate its version</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d24443e38 ">Rule Engine Designer</td>

          </tr>
        </tbody>
      </table>

The field alias (Applicant.Birthdate) for using the value of the Birthdate field from the Contact object must be created in Setup, and available to use in the expression set. See [Create Source Field Aliases](https://help.salesforce.com/s/articleView?id=ind.create_source_field_aliases.htm&type=5&language=en_US).

Create an expression set named AnnualGymMembership. In Version 1 of this expression set, add steps to use the contact’s inputs and return the discounted gym membership fees.

1. From the app navigation menu of Business Rules Engine, select **Expression Sets**.
2. Click **New**.
3. Enter AnnualGymMembership as the name, and save your work.
    
    The expression set and its first version are created.
4. On the record page for the new expression set, on the Versions tab, select **AnnualGymMembership V1**, and then click **Open in Expression Set Builder**.
5. Set the properties for the expression set version:
    1. Click ![Gear icon, which opens the properties panel.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-business_rules_engine-264-0-0-production-enus/b2d6dd5c-c231-428b-abbf-3dd2cd51a11f/business_rules_engine/images/properties_gear_icon.png), and enter a start date time for the expression set version.
    2. Enter a rank.
        
        The default is 1.
    3. Select **Show decision explanation**.
    4. Close the Expression Set Properties panel.
6. Create resources for the expression set:
    
    1. Click ![resource manager icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-business_rules_engine-264-0-0-production-enus/b2d6dd5c-c231-428b-abbf-3dd2cd51a11f/business_rules_engine/images/resource_manager.png).
    2. Click **Add Resource**, and then create these variables and constants.
        
        ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-business_rules_engine-264-0-0-production-enus/b2d6dd5c-c231-428b-abbf-3dd2cd51a11f/images/icon_note.png)
        
        Note After adding a resource, to add the next resource, click **Done and New**. After adding all required resources, click **Done**.
        
        Resources     
        | Resource Type | Variable NAME | Data Type | Decimal | Default Value |
        | --- | --- | --- | --- | --- |
        | Constant | GymFees | Currency | 0 | 1000 |
        | Variable | ContactAge | Number | 0 | — |
        | Variable | TotalDiscount | Percent | 0 | — |
        | Variable | DiscountedGymFees | Currency | 2 | — |
    
    ![Tip](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-business_rules_engine-264-0-0-production-enus/b2d6dd5c-c231-428b-abbf-3dd2cd51a11f/images/icon_tip.png)
    
    Tip Save the version after making any change.
7. To get the discount percent based on the step count, add a Lookup Table step.
    1. Click ![Add icon in expression set builder canvas.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-business_rules_engine-264-0-0-production-enus/b2d6dd5c-c231-428b-abbf-3dd2cd51a11f/business_rules_engine/images/add_element_icon.png) on the builder canvas, and select **Lookup Table**.
    2. Search for and select **StepsBasedDiscount**.
        
        The matrix is added and the input and output columns from the matrix appear as local variables in the resources list.
8. To calculate the contact’s age from their birth date, add a Calculation step.
    1. Click ![Add icon in expression set builder canvas.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-business_rules_engine-264-0-0-production-enus/b2d6dd5c-c231-428b-abbf-3dd2cd51a11f/business_rules_engine/images/add_element_icon.png) on the builder canvas, and select **Calculation**.
    2. In the Formula field, search for and select **AGE (Date)**.
    3. To replace Date in Age (Date) with the value of the Birthdate field on the Contact object, search for and select **Applicant.Birthdate** so that the formula looks like this: Age(Applicant.Birthdate).
        
        Here. Applicant is the object alias for Contact, and Birthdate is the field alias for the Birthdate field in Contact.
    4. In the Output Variable field, search for and select **ContactAge**.
9. To use the contact’s age to a get the applicable age-based discount, add a Lookup Table step.
    1. Click ![Add icon in expression set builder canvas.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-business_rules_engine-264-0-0-production-enus/b2d6dd5c-c231-428b-abbf-3dd2cd51a11f/business_rules_engine/images/add_element_icon.png) on the builder canvas, and select **Lookup Table**.
    2. Search for and select **AgeBasedDiscount**.
        
        The matrix is added and the input and output columns from the matrix appear as local variables in the resources list.
10. To calculate the total discount based on the contact’s age and step count, add a Calculation step.
    1. Click ![Add icon in expression set builder canvas.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-business_rules_engine-264-0-0-production-enus/b2d6dd5c-c231-428b-abbf-3dd2cd51a11f/business_rules_engine/images/add_element_icon.png) on the builder canvas, and select **Calculation**.
    2. In the Formula field, enter this formula: `StepBasedDiscount_Discount + AgeBasedDiscount_Discount`.
    3. In the Output Variable field, search for and select **TotalDiscount**.
11. To calculate the discounted gym membership fees, add a Calculation step.
    
    1. Click ![Add icon in expression set builder canvas.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-business_rules_engine-264-0-0-production-enus/b2d6dd5c-c231-428b-abbf-3dd2cd51a11f/business_rules_engine/images/add_element_icon.png) on the builder canvas, and select **Calculation**.
    2. In the Formula field, enter this formula: `GymFees - ( TotalDiscount * GymFees ).`
    3. In the Output Variable field, search for and select **DiscountedGymFees**.
    
    ![End-to-end steps in the expression set version.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-business_rules_engine-264-0-0-production-enus/b2d6dd5c-c231-428b-abbf-3dd2cd51a11f/business_rules_engine/images/gym_membership_es.png)
12. Select each step individually, click ![Open element details panel.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-business_rules_engine-264-0-0-production-enus/b2d6dd5c-c231-428b-abbf-3dd2cd51a11f/business_rules_engine/images/elements_panel_icon.png), and select Include in output.
    
    ![Tip](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-business_rules_engine-264-0-0-production-enus/b2d6dd5c-c231-428b-abbf-3dd2cd51a11f/images/icon_tip.png)
    
    Tip To save the version, this action is required for at least one step. However, to include step-wise details in the Decision Explainer logs, complete this action for every step.
13. Click **Simulate** and test the version by entering sample inputs.
14. Activate the version.