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. Let's look at the pros and cons of each.
1. Calling a clear process from TM1py
Execute }bedrock.cube.data.clear using tm1.processes.execute_with_return:
Intuitive, but less flexible than MDX approaches, can't clear over alternate hierarchies, and can break if element names contain separation characters.
2. C spread on a consolidated cell
Use cells.clear_spread by referencing one element or consolidation for each dimension:
Intuitive but slower than all other options.
3. Clear with MDX
Define a slice with MDX and call cells.clear_with_mdx:
Maximum flexibility through MDX. Requires admin permissions, verbose, error prone (all dimensions must be referenced), and requires TM1 11.7 minimum.
4. Use the new clear method (TM1py 1.5+)
cells.clear enables clearing without MDX or referencing all dimensions. If a dimension is not referenced, all leaves will be cleared:
Maximum flexibility, intuitive, concise, and easy to use. Requires admin permissions and TM1 11.7 minimum.