Free Text Dimension Attributes in SSASAugust 25th, 2012 | Posted by in Analysis Services
In some cases we need to bring comments or descriptions into a dimension in SSAS for detail reporting. For example the comment from a maintenance worker against a machine breakdown, or a geological survey description. These fields are typically free text in the source system and as such don’t contain restrictions or constraints on data entry (e.g. upper and lower case, empty values, white-space, uniqueness). When you try and process these attributes you’ll run into a couple of issues.
To demonstrate this I’ve knocked up a few rows with variations in case of the same text, a null value and an empty string.
Creating a dimension based on this table in SSAS gives the following error when we try to process it – “Errors in the OLAP storage engine: A duplicate attribute key has been found when processing: Table: ‘dbo_FreeText’, Column: ‘Comment’, Value: ”. The attribute is ‘Comment’”.
This is due to the NullProcessing property on the dimension attribute, for which the default setting is Automatic. This specifies that the Null value is converted to zero (for numeric data items) or in this case a blank string (for string data items). This means that we’ve now got a null value which is converted to an empty string and an empty string, resulting in duplicate key values. If we set NullProcessing to Preserve this will fix this, giving us two distinct key values. If your database or this particular field is case sensitive you’ll then likely run into a second issue with a very similar error message – “Errors in the OLAP storage engine: A duplicate attribute key has been found when processing: Table: ‘dbo_FreeText’, Column: ‘Comment’, Value: ‘Some comment’. The attribute is ‘Comment’”. This comes down to a difference in case sensitivity between the underlying database and Analysis Services, which by default is case insensitive. In SSAS this is set at the attribute level. If you select the Comment attribute and expand they KeyColumns group you’ll find the collation property, under which you’ll find a case sensitive check box.
Once you’ve checked this the dimension should now process successfully. When we browse the comment attribute you’ll notice two “blank” values (null and empty) and multiple values for “some comment”. This example assumes that these are different discrete values. If this isn’t the case this should be handled in ETL i.e. converting null values to empty strings and standardising on case.