Here is how to simply delete a single element from a dimension in TM1. Note DimensionElementDelete permanently deletes the element from the TM1 dimension and all associated data from any cube the dimension is in – so please be careful!
Syntax of DimensionElementDelete
The syntax is:
DimensionElementDelete ( dimension , element ) ;
where
- dimension – is the name of the dimension that you want to delete an element from
- element – is the name of the element that you want to delete from the dimension
Example
DimensionElementDelete ( 'Product', 'Shoes');
This example deletes the element ‘Shoes’ from the ‘Product’ dimension.
Usage
Often we will use this function alongside the DIMIX and IF functions, so we end up with TI code that looks like this:
DimName = 'Product'
Element = 'Shoes'
IF ( DIMIX ( DimName , Element ) > 0 );
DimensionElementDelete ( DimName , Element ) ;
ENDIF;
This sets up the variables for the dimension name and element, then uses DIMIX to check if the element exists in the dimension and if it does, then it deletes it.
Warning about DimensionElementDelete!
DimensionElementDelete obviously deletes an element from a dimension. Thanks Mr Holmes. Remember, though, that if you have data on any element that is deleted where this dimension is used, that data will also be deleted. So please be careful!
Notes
As stated above, this function will delete the element from the dimension and all data associated with the element in any cube where it is used.
If you are looking to delete an element from a parent, but leave the element still in the dimensions, just not as a child to the parent, please use DimensionElementComponentDelete.
This function is the opposite of DimensionElementInsert.