Desktop User Guides > Professional > Table scripting > Working with metadata > Working with labels
Working with labels
Sample script file: WorkingWithLabels.mrs
This example script is based on the Museum sample data set. See Running the sample table scripts for information on running the example scripts.
By default, UNICOM Intelligence Reporter creates labels for the axes and elements in your tables from the labels in the variables and categories on which they are based.
Axis and element labels in a table
This graphic is described in the surrounding text.
In the MDM Document, labels for variables and elements are stored in a two-dimensional array for each language, in which the dimensions are user contexts and label types.
User contexts. These define different usages for the metadata, so that different texts and custom properties can be used depending on how the metadata is being used. For example, the Question user context is typically used to define the texts for use during interviewing and the Analysis user context is typically used to define shorter texts for use when analyzing the response data.
Label types. These enable different types of labels to be created for different types of information. For example, the default label type of Label is used for question and category texts and variable descriptions, and the Instruction label type is used for interviewer instructions.
By default, UNICOM Intelligence Reporter creates the axis and element labels from the variable and element labels in the Analysis user context and the default label type. However, you can change the user context and the label type if necessary, using the Document.Context and Document.LabelType properties. For example, to use the Question user context, set the Document.Context property to "Question":
TableDoc.Context = "Question"
Note that changing the user context or label type in the table document does not change the current user context or label type for the MDM document, which is exposed through the Document.MDMDocument property.
Sometimes, you might want to use a user context that does not have texts for all the variables and categories you want to use. When this happens, you can define an alternative context to be used when texts are not available in your first choice user context. For example, to specify that texts should be taken from the Analysis user context when they are not available in the Question user context, use a script like this:
You can overwrite the labels that the Table Object Model creates for an axis using the Axis.Label property. For example, the following statement changes the label of the expect axis, which is on the side of the table:
MyTable.Side.expect.Label = "Expectation of visit"
This example uses the dynamic property expansion feature of mrScriptBasic, which enables you to access the expect item as if it is a property of the Side axis. You cannot use this feature with variables that have a period (.) in their name (for example, variables that are inside a grid or loop). For these variables, you define the axis label like this:
MyTable.Side.SubAxes["expect"].Label = "Expectation of visit"
To change the label for use in multiple tables, it is easier to change it in the MDM Document, because then it applies to all tables. For example:
TableDoc.DataSet.MDMDocument.Fields["expect"].Label = "Expectation of visit"
The MDM Document is opened in no-save mode, which means that any changes you make are not saved.
You can overwrite the labels that the Table Object Model creates for an element using the Element list syntax or the Element.Label property. For example, if you want to change the label on the autobase element to read "Total" instead of "Base", you can use script similar to the following:
MyTable.Side.MyAxis.Elements.Base.Label = "Total"
When defining labels for axes and elements, the language is assumed to be the currently selected language if you do not specify otherwise. If you are working in a multilingual environment and want to specify a label for a different language, you simply specify the language code. See Working with languages for more information.
When you export your tables, you can optionally export the axis and element names instead of the labels. You do this by setting the UseVariableLabels and UseElementLabels export properties to False. For example:
TableDoc.Exports["mrHtmlExport"].Properties["UseVariableLabels"] = False
See also
A complete example
Working with metadata