Tips for Creating Member Properties for Multiple Languages

Analysis Services Programming

Analysis Services Programming

Tips for Creating Member Properties for Multiple Languages

The Caption and Language properties of the DSO.MemberProperty object allow you to tailor member properties to users with specific language requirements. With this feature, a single cube can serve groups of users without a common language.

When a client application's query involves member properties with identical captions, the Analysis server uses the member property object whose Language property most closely matches the application's LocaleID value. Multiple member properties can have identical values for Caption only if they each have a different value for the Language property, so that the member property most appropriate for the LocaleID value of the client application can be used. For a cube that serves client applications in only one language, the Language property for each member property object should be set to languageAny.

The Name property of a clsMemberProperty object contains the name of the source column for the data contained in the member property. The Caption property contains the name of the member property as it appears to the client application.

Add Members Properties for Multiple Languages

The following code example creates two member properties for Store Manager in the TestDB database. One is for English-speaking users, the other for Spanish-speaking users.

Example

The following code example adds a new member property, Store Manager, for English and Spanish languages:

Private Sub AddMultiLangMembers()
    Dim dsoServer As New DSO.Server
    Dim dsoDB As DSO.MDStore
    Dim dsoDS As DSO.DataSource
    Dim dsoDim As DSO.Dimension
    Dim dsoLevel As DSO.Level
    Dim dsoMember As DSO.MemberProperty
    
    Dim strDBName As String
    Dim strLQuote As String
    Dim strRQuote As String
    
    ' Define constants used for the ColumnType property
    ' of the DSO.Level object.
    ' Note that these constants are identical to
    ' those used in ADO in the DataTypeEnum enumeration.
    Const adWChar = 130
    
    ' Initialize variables for the database name.
    strDBName = "TestDB"
    
    ' Create a connection to the Analysis server.
    dsoServer.Connect "LocalHost"
    
    ' Set the database object.
    Set dsoDB = dsoServer.MDStores(strDBName)
    
    ' Set the data source for the database object.
    ' A data source is required to run this example.
    If dsoDB.DataSources.Count = 0 Then
        MsgBox "Database " & dsoDB.Name & _
            " has no data sources."
    Else
        Set dsoDS = dsoDB.DataSources(1)
    End If
   
    ' Get database-specific delimiter characters.
    strLQuote = dsoDS.OpenQuoteChar
    strRQuote = dsoDS.CloseQuoteChar
    
    ' Retrieve the Store dimension.
    Set dsoDim = dsoDB.Dimensions("Stores")
    
    ' Retrieve the Store ID level.
    Set dsoLevel = dsoDim.Levels("Store ID")
    
    ' First, create the English (and default) member property.
    Set dsoMember = dsoLevel.MemberProperties.AddNew("Store Manager")
    dsoMember.SourceColumn = strLQuote & "store" & strRQuote & "." & _
                               strLQuote & "store_manager" & strRQuote
    dsoMember.ColumnSize = 255
    dsoMember.ColumnType = adWChar
    dsoMember.Caption = "Store Manager"
    dsoMember.Language = languageAny
    ' Next, create an identical one for Spanish users.
    Set dsoMember = _
                dsoLevel.MemberProperties.AddNew("Encargado de Almacén")
    dsoMember.SourceColumn = strLQuote & "store" & strRQuote & "." & _
                               strLQuote & "store_manager" & strRQuote
    dsoMember.ColumnSize = 255
    dsoMember.ColumnType = adWChar
    dsoMember.Caption = "Store Manager"
    dsoMember.Language = languageSpanish
    
    ' Update the Stores dimension.
    If dsoLevel.IsValid And dsoDim.IsValid Then
        dsoDim.Update
    End If

End Sub