Often when interacting with TM1 through TM1py, it is necessary to clear out a slice of a cube. Since release 1.5 there are four options to clear a slice in a cube. Let’s look at the pros and cons of each option.
Calling a clear process from TM1py
From TM1py, any process can be executed using the method, tm1.processes.execute_with_return. To clear data from a cube, }bedrock.cube.data.clear can be used:
-
Intuitive
-
Less flexible than MDX based approaches
-
Can’t clear over alternate hierarchies
-
Can break if element names contain separation characters
C spread on a consolidated cell
With the cells.clear_spread method, you can define a slice of a cube by referencing one element or consolidation for each dimension:
-
Intuitive
-
Slower than all other options
Clear with MDX
Define a slice of a cube with MDX and then call the method cells.clear_with_mdx:
-
Maximum flexibility through MDX
-
Requires admin permissions
-
Verbose
-
Error prone. All dimensions have to be references explicitly
-
Requires TM1 11.7 as minimum
Use the new clear method introduced with TM1py 1.5
TM1py v1.5 introduced a new method cells.clear enabling you to clear data from a cube without using MDX or referencing all dimensions (If a dimension is not referenced, all leaves will be cleared).
-
Maximum flexibility through MDX
-
Intuitive
-
Concise
-
Easy to use
-
Requires admin permissions
-
Requires TM1 11.7 as minimum