Role-Playing Relationships
Whenever you create a relationship to a dimension, whether from a fact table to a dimension or from one dimension to another dimension, an instance of that dimension is added to the model. In some cases, the same dimension may be referenced in more than one context in the same model. A role-playing relationship is what differentiates multiple instances of the same dimension in a model.
Basics of Role-Playing
For example, suppose that you want to create a relationship between the orderdatekey and shipdatekey keys in a fact dataset and the Day level in the Date Month and Date Week hierarchies in the Date dimension. The results would look like the top four relationship lines of the model below:
Figure 1. Role-playing relationships: The Date dimension is in relationships to orderdatekey and shipdatekey in a fact dataset. The top four relationships trace to the Month and Week Hierarchies of the Date Dimension.
The Date dimension is in relationships with orderdatekey and shipdatekey. Each relationship is labeled with a role-playing name.
To create this relationship, you first drag orderdatekey to the Day level. The Relationship properties panel opens. In the Role-Playing Template field, you use the dimension variable {0} to insert the role-played dimension name like this: "Order {0}"
You use the dimension variable {0} to determine whether the template is a prefix, suffix, or both. For example:
- Prefix: "Order {0}"
- Suffix "{0} Order"
- Prefix and Suffix: "Order {0} Sales"
If you enter a value in the Role-Playing Template field that does not include the dimension variable {0}, AtScale assumes that the input is a prefix and appends {0} to the value when you save.