![]() |
| Contents > Choosing the evaluation context for a calculation field | |
|
|
| Choosing the evaluation context for a calculation field |
| Context is the table in the relationships graph from which a relationship is evaluated. When you define a calculation in a source table, and the table has more than one occurrence in the relationships graph, you must specify the context from which you want the calculation to evaluate. |
| An example of how context changes the results of a calculation |
| You have a database with two source tables named ColorsSourceTable and ShapesSourceTable. The tables have these properties: |
|
|
| The tables are related as follows: |
| There are two separate relationships: |
| In the first, ColorsTable 1 and ShapesTable are related using the Style Number fields. |
| In the second, ColorsTable 2 and ShapesTable are related using the Weight fields. |
|
|
| A single record in the ColorsSourceTable has these values: |
|
|
| Because the relationships use different match fields, each relationship returns a different set of related records. |
| Calculation result 1 |
| The relationship between ColorsTable 1 and ShapesTable, which uses Style Number as the match field, returns these two records: |
|
|
| A calculation field defined in the ColorsSourceTable with the formula Sum(ShapesTable::Price) that is set to evaluate from the context of the table ColorsTable 1 returns the value $8.00. |
| Calculation result 2 |
| The relationship between ColorsTable 2 and ShapesTable, which uses Weight as the match field, returns these two records: |
|
|
| A second calculation field defined in the ColorsSourceTable with the same formula, Sum(ShapesTable::Price), but set to evaluate from the context of the table ColorsTable 2 returns the value $15.00. |
| Notes |
| When constructing a calculation formula, evaluation context determines which tables appear as related and unrelated in the Specify Calculation dialog box. |
| A calculation formula can use global fields from unrelated tables. These are the only fields that can be used from unrelated tables. |
| Related topics |
| About relationships |
| Defining calculation fields |
| About formulas |
|
|
| Contents > Choosing the evaluation context for a calculation field |