cubewise-code / tm1py

TM1py is a Python package that wraps the TM1 REST API in a simple to use library.
http://tm1py.readthedocs.io/en/latest/
MIT License
188 stars 109 forks source link

PowerBI GetMemberProperties without ElementAttributesCube #499

Closed scrumthing closed 2 years ago

scrumthing commented 3 years ago

Describe the bug It is not possible to retrieve only the consolidations for a hierarchy/dimension if there exists no attribute cube.

To Reproduce

    tm1_dim_chartofaccounts = tm1.power_bi.get_member_properties(
            dimension_name="d1",
            hierarchy_name="d1",
            skip_consolidations=True,
            attributes="")

Expected behavior Retrieval of hierarchy should always be possible. even if no attributes are defined.

MariusWirtz commented 3 years ago

The }ElementAttributes_ cubes must exist because we query the parent information from each element through calculated members. In order to execute this query, a cube must exist.

The MDX query looks kinda like this:


        WITH 
                    MEMBER [}ElementAttributes_plan_department].[level001] 
                    AS [plan_department].CurrentMember.Parent.Name

                    MEMBER [}ElementAttributes_plan_department].[level000] 
                    AS [plan_department].CurrentMember.Parent.Parent.Name

        SELECT
        { [plan_department].[plan_department].[105],[plan_department].[plan_department].[110],[plan_department].[plan_department].[115],[plan_department].[plan_department].[200],[plan_department].[plan_department].[300],[plan_department].[plan_department].[405],[plan_department].[plan_department].[410],[plan_department].[plan_department].[415] } ON ROWS,
        { {Tm1SubsetAll([}ElementAttributes_plan_department])} + {[}ElementAttributes_plan_department].[level001],[}ElementAttributes_plan_department].[level000]} } ON COLUMNS
        FROM [}ElementAttributes_plan_department]  

Just a create the cube :)

scrumthing commented 3 years ago

Unfortunately the customer has only read access to the system and certain cubes. For some dimension there are no attributes defined. Couldn't we find another workaround here?

MariusWirtz commented 3 years ago

So far it has never been an issue. If a dimension has no attributes at all, then typically it doesn't have a complex hierarchy structure either. Also, you don't have to bring every dimension to PBI that is part of a cube. You can bring the ones that are relevant for analysis.

If you still think it's necessary, we can build it but it's a huge refactoring exercise because of how the levels are currently retrieved through calculated members.

scrumthing commented 3 years ago

You do not know the kind of tm1 instances we have here. ;-) We have some large dimensions without any attributes but very complex custom rollups. For now I convinced them to create an empty attributes cube. But maybe for the future there is a better way.

MariusWirtz commented 3 years ago

We will look into this but not short term. If you need this short term, I'm happy to accept a PR :)