Analysis Services Programming

RelatedColumn (clsColumn)

The RelatedColumn property of a clsColumn identifies a column to which the column is related.

Data Type

String

Access

Read/write for columns with a SubClassType of sbclsRegular whose IsKey property is False, read-only for all others.

Remarks

For columns with a SubClassType of sbclsRegular whose IsKey property is set to True and for columns with a SubClassType of sbclsNested, this property returns an empty string.

The functionality of the RelatedColumn property differs depending on the context of its usage:

Examples
A. Creating a Key Column and Relating it to a Key in the Case Table

The following example creates a key column in the case table for a mining model. It then creates a nested table based on three different tables and establishes the relationships between them (that is, their joins). Finally, it establishes a key column within this nested table and relates it to the key column in the case table.

'Define the key column for the case table.
Set dsoColumn = dsoDmm.Columns.AddNew("KeyColumn")
dsoColumn.SourceColumn = "Key"
dsoColumn.DataType = adInteger
dsoColumn.IsKey = True

'Define a nested table and relate the tables it is based on in a join.
Set dsoNestedCol = dsoDmm.Columns.AddNew("Products", sbclsNested)
dsoNestedCol.FromClause = "Sales, SalesReps, Products"
dsoNestedCol.JoinClause = "Sales.SalesRep = SalesReps.Name " & _
    "AND Sales.Product = Products.Product"
dsoNestedCol.Filter = ""

'Create a parent key column for the nested table and relate it to a column in the case table.
Set dsoColumn = dsoNestedCol.Columns.AddNew("CustomerID")
dsoColumn.SourceColumn = "CustId"
dsoColumn.DataType = adInteger
dsoColumn.IsParentKey = True
dsoColumn.RelatedColumn = "KeyColumn"
B. Establishing a Hierarchical Relationship Between Columns in a Nested Table

The following example builds a hierarchical relationship between the columns as they are added to a nested table. The following diagram shows their structure.

Set dsoColumn = dsoNestedCol.Columns.AddNew("Product Name")
dsoColumn.SourceColumn = "Sales.Product"
dsoColumn.DataType = adWChar
dsoColumn.IsKey = True

Set dsoColumn = dsoNestedCol.Columns.AddNew("Product Type")
dsoColumn.SourceColumn = "Products.Type"
dsoColumn.DataType = adWChar
dsoColumn.RelatedColumn = "Product Name"

Set dsoColumn = dsoNestedCol.Columns.AddNew("Product Category")
dsoColumn.SourceColumn = "Products.Category"
dsoColumn.DataType = adWChar
dsoColumn.RelatedColumn = "Product Type"

Set dsoColumn = dsoNestedCol.Columns.AddNew("Aisle")
dsoColumn.SourceColumn = "Products.Aisle"
dsoColumn.DataType = adWChar
dsoColumn.RelatedColumn = "Product Name"
C. Establishing a Probabilistic Relationship

The following example adds a column to a nested table. It then adds a second column whose contents will contain a probability based upon the first column.

Set dsoColumn = dsoNestedCol.Columns.AddNew("Quantity")
dsoColumn.SourceColumn = "Sales.Quantity"
dsoColumn.DataType = adDouble
dsoColumn.ContentType = "CONTINUOUS"

Set dsoColumn = dsoNestedCol.Columns.AddNew("pQuantity")
dsoColumn.SourceColumn = "Sales.pQuantity"
dsoColumn.DataType = adDouble
dsoColumn.RelatedColumn = "Quantity"
dsoColumn.SpecialFlag = "PROBABILITY"

See Also

clsColumn