DimensionDeleteAllElements: Use, Syntax and Example

Have you ever needed to just delete all elements from a dimension in TM1? Well there is a super easy function that does just this. Using DimensionDeleteAllElements, then one click and zap, they’re gone.

Syntax of DimensionDeleteAllElements

The syntax is:

DimensionDeleteAllElements(DimName);

where DimName is the name of the dimension you want to delete all elements from.

Example of DimensionDeleteAllElements

Prolog Tab

DimName = Customer;
DimensionDeleteAllElements(DimName);

This will delete all elements from the Customer Dimension.

Warning about DimensionDeleteAllElements!

DimensionDeleteAllElements obviously deletes all elements from a dimension. Thanks Sherlock. Remember, though, that if you have data on any element in any cube where this dimension is used, that data will also be deleted.

However it Might Not Delete All Data…

Yes, there’s a catch to that statement immediately above. If you re-add those elements on the Metadata tab of the same TI, then the data will not be lost for the recreated elements.

Therefore, if you, say had the following in a TI:

Prolog Tab

DimName = Customer;
DimensionDeleteAllElements(DimName);

Metadata Tab

DimensionElementComponentAdd ( DimName, vCustomer);

Then the code in the Prolog will delete all elements from the Customer dimension. The code then in the Metadata tab will add all data from the vCustomer variable back into the Customer dimension.

So, assuming that customer ABC123 was originally in the Customer dimension and they had vales in a Sales cube, and ABC123 was in the source data, they would be reinstated by the DimensionElementComponentAdd and all existing data kept regardless of the delete.

Summary

DimensionDeleteAllElements is a really powerful TI function. Just use it carefully. Maybe make sure you have a backup before you use it for the first time!

You might also like