Tm1py: How to get the rule from a cube?

Created on 20 Oct 2020  路  2Comments  路  Source: cubewise-code/tm1py

Hi All,
I'm trying to validate dimension changes in a TM1 model. One step of the validation is to ensure that elements that may no longer be in some dimensions are not referenced in any rule (specifically Consolidated elements on hierarchies).
To do that I would need to scan the rule of a cube and search for specific strings that reference the elements to be deleted.

I checked in the current library but I don't see a function for it (I think). Technically this could be achieved by:
https://<tenant>.planning-analytics.ibmcloud.com/tm1/api/<instance>/api/v1/Cubes('name')?$select=Rules --> is that accurate?
Is there any way of getting this with TM1Py? I'm using v1.5.0

Thanks!

nico

question

Most helpful comment

Hi Nico,

rules is a property of a cube. You can access them like this:

from TM1py.Services import TM1Service
tm1 = TM1Service()

# Get all cube names
all_cubes = tm1.cubes.get_all_names()

# Loop through the cube names
for cube_name in all_cubes:
    # Get the cube details
    cube = tm1.cubes.get(cube_name)
    # Access the rules property
    cube_rule = cube.rules

    print(cube_rule)

All 2 comments

Hi Nico,

rules is a property of a cube. You can access them like this:

from TM1py.Services import TM1Service
tm1 = TM1Service()

# Get all cube names
all_cubes = tm1.cubes.get_all_names()

# Loop through the cube names
for cube_name in all_cubes:
    # Get the cube details
    cube = tm1.cubes.get(cube_name)
    # Access the rules property
    cube_rule = cube.rules

    print(cube_rule)

That's exactly what I needed!

Thanks a lot, Vinoth!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cubewise-gng picture cubewise-gng  路  3Comments

yyzz1010 picture yyzz1010  路  3Comments

hermie64 picture hermie64  路  4Comments

hermie64 picture hermie64  路  3Comments

fidong picture fidong  路  3Comments