70+ ready-to-use samples, just download the folder from GitHub and try them out.

Using the TM1py Samples is the best way to get started with TM1py. With these samples you will learn for example how to:

  • Upload exchange rate from a web service
  • Cleanup your TM1 application
  • Find unused dimensions

Examples

Reschedule all chores on one instance by – 1 hour:

with TM1Service(address=’localhost’, port=8001, user=’admin’, password=’apple’, ssl=True) as tm1:

for chore in tm1.chores.get_all():

chore.reschedule(hours=-1)

tm1.chores.update(chore)

Find unused dimensions

from TM1py.Services import TM1Service

# Connect to TM1

with TM1Service(address=’localhost’, port=8001, user=’admin’, password=’apple’, ssl=True) as tm1:

# get all dimensions

all_cubes = tm1.cubes.get_all()

# find user dimensions

used_dimensions = set() for cube in all_cubes: used_dimensions.update(cube.dimensions)

# determine unused dimensions

unused_dimensions = set(all_dimensions) – used_dimensions

print(unused_dimensions)

Generate a TM1 MDX Query from cube view

from TM1py.Services import TM1Service

# Establish connection to TM1 Server

with TM1Service(address=’localhost’, port=8001, user=’admin’, password=’apple’, ssl=True) as tm1:

# Instantiate TM1py.NativeView object

print(nv.MDX)