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 tow 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.

AttrClear Function

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”.

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!

Download the Zip File here

If you like this post, please spread the love…

About John

Managing Director of Infocube. We are a management accounting consultancy that specialises in Business Analytics.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.