BEFORE

Takes the child records for each parent and sorts them by the field specified in the field_name parameter. Then checks the source query against the target query and returns True if any of the records in the source query come before those in the target query, otherwise the function returns False. If the optional filter query is supplied then the records in the source and target query are filtered so that only records that match the criteria are evaluated.

BEFORE ( <field_name>, <source_query>, <target_query> [, <filter_query>] )
  • field_name: The field by which to sort the records.

  • source_query: A query string that represents the set of records to check.

  • target_query: A query string that represents the set of records to check.

  • filter_query: A query string to restrict the records being checked.

Example: create a field on the CUSTOMER table to flag customers who have bought a product with product code R before (sorted on purchase date) they bought a product with product code B where the product value was greater then 25.

BEFORE( [PRODUCT.PRODUCT_PURCHASE_DATE], [PRODUCT.PRODUCT_CODE] = "B", [PRODUCT.PRODUCT_CODE] = "R",[PRODUCT.PRODUCT_VALUE] >25)