TM1 Clear Attribute – an AttrClear Function
We have a client where we need to update a Relative Time attribute on a time dimension each month so that the new month is referred to as “Current Month” and the now just completed month is referred to as “Prior Month”. As you would know, you can’t have an alias with the same values on two elements, so we couldn’t just overwrite the existing values. We needed to clear the current values and then change it to what we wanted. In essence, we wanted an AttrClear or ClearAttr function. But such a beast does not exist in TM1.
Delete and Re-Add Alias
One method to overcome this is to just delete the alias and then re-add it and then define the contents as required. This is fine, but for some reason was causing our model to crash.
The method we went with is really what an AttrClear or ClearAttr TM1 function would do. We set up a view on the control cube for the Time dimension that only contained the Relative Time attribute. Then we cleared the contents of that view entirely prior to redefining which months are “Current Month” and “Prior Month”.
Download the Zip File here
We’ve developed a simple TI that you can add into your TM1 model that does this “function” for you.
Working Example to Clear an Attribute
Attached you will find a zip file with the following contents:
- the “Test Clear Attribute” dimension, with an attribute defined for Description
- Control Objects for:
- the attribute dimension for the “Test Clear Attribute” dimension
- the cube for the “Test Clear Attribute” dimension
- “Infocube.CubeViewBuild” process – that clears a defined view of a cube
- “zTest Clear Attribute” process – that clears the contents of the “Description” attribute on the “Test Clear Attribute” dimension.
To see how it works do the following:
- Unzip this file and copy to a test TM1 model and restart it.
- Then open the attributes on the “Test Clear Attribute” dimension and check that there’s something in there.
- Run the TI “zTest Clear Attribute”. This will clear the contents of the Description attribute.
Obviously if you need any help with it, give us a yell at Infocube!