3 Replies Latest reply: Apr 27, 2012 4:04 PM by Matt Sevin-Oracle RSS

    rule question

    user36
      I am working on a calculation that involved referencing a rule table, now the source material asks that we pick the highest number from two diferent tables and apply that to the calculation

      the exact wording is:

      the greater of:
      the amount specificed in table 1 or
      the amount specified in table 2

      This seems pretty simple but we are trying to think of a good way of doing this, can someone help?

      Edited by: user36 on 27-Apr-2012 07:00
        • 1. Re: rule question
          Matt Sevin-Oracle
          Define your calculation rule using a single attribute. For example, the total = the first number + the greater of the possible second numbers, where "the greater of the possible second numbers" is an attribute. Use a rule table to determine "the greater of the possible second numbers" from "the value from table 1" and "the value from table 2" by using a comparison to determine which is greater. For simplicity, Z = X if X > Y and Z = Y otherwise might appear as follows in a table:
          ____Condition (X)____| _ Conclusion (Z)____
          _______ > Y _______| _____ X ______
          ______ otherwise ___| _____ Y _______

          With this approach you separately determine "the greatest ...." according to whatever logic is necessary and you use the single determined value "the greatest ... " in your formula regardless of how it was determined. This approach also makes it easier to maintain the rules because the formula and the logic that dictates which factors to use in a formula are in separate rules/tables. (which also leads to more meaningful decision / audit reports when needed)
          • 2. Re: rule question
            Jasmine Lee-Oracle
            How about just using the Maximum function? For example:

            the result = Maximum(the amount specified in table 1, the amount specified in table 2)

            Or the natural language version of the same rule:

            the result = the greater of the amount specified in table 1 and the amount specified in table 2

            Where the variables are:

            the result
            the amount specified in table 1
            the amount specified in table 2

            Cheers,
            Jasmine
            • 3. Re: rule question
              Matt Sevin-Oracle
              Yes, Maximum also works for this specific example. The approach shown was the more general approach for when the logic of which to choose is not exactly the same as an existing function, or when factors other than the values themselves are required in the "selection" logic. i.e. a third table is added and "greatest" changes to greatest between X and Y before this date but use value from table 3 after this date, etc.