Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting all the views from a TM1 cube #662

Closed
marmar1020 opened this issue Jan 9, 2022 · 2 comments
Closed

Getting all the views from a TM1 cube #662

marmar1020 opened this issue Jan 9, 2022 · 2 comments
Labels

Comments

@marmar1020
Copy link

marmar1020 commented Jan 9, 2022

Hello All,

I was searching around the samples folder but was successful. Is there a way to (1) get all the view from a TM1 cube (2) get a list of TM1 cube from a server?

Attempting to get a list of views in a cube as coded:

with TM1Service(address="XX.XX.XX.X", port=XXXX, ssl=True, namespace="XXX", gateway="http://xxxxx:x0/xxxx/xx/xx/disp") as tm1:
print(TM1py.ViewService.get_all('CubeName'))

Error received:

TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_22792/967449712.py in
1 with TM1Service(address="XX.XX.XX.X", port=XXXX, ssl=True, namespace="XXX", gateway="http://xxxxx:x0/xxxx/xx/xx/disp") as tm1:
----> 2 print(TM1py.ViewService.get_all('CubeName))
3

TypeError: get_all() missing 1 required positional argument: 'cube_name'

Thanks

@marmar1020 marmar1020 changed the title Saving TM1 Cube data to dataframe output - column headers/values all in one row Getting all the views from a TM1 cube Jan 9, 2022
@gbryant-dev
Copy link
Contributor

Hi @marmar1020,

The problem is the way you're accessing the ViewService. It should be accessed through the TM1Service e.g tm1.cubes.views.get_all(cube_name) or tm1.views.get_all(cube_name)

Depending on the information you're after, you can either use the get_all_names functions or get_all. Some examples below.

with TM1Service(...) as tm1:
    # Get all cube names
    cube_names = tm1.cubes.get_all_names()
    # Get all view names for the Revenue cube
    revenue_view_names = tm1.cubes.views.get_all_names('Revenue')

    # Get all cubes, along with their rules and dimensions 
    cubes = tm1.cubes.get_all()
    # Get all views for the Revenue cube, along with their dimension arrangement if `NativeView` or MDX statement if `MDXView`
    revenue_views = tm1.cubes.views.get_all('Revenue')

Hope this helps.

George

@marmar1020
Copy link
Author

George,

Thank you for the information. I was able to extract cube data based on your examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants