Skip to content

MDXView: Support additional body properties (e.g., Meta, IsAutocalculate) #1362

@151N3

Description

@151N3

Feature Request

Currently MDXView.construct_body() only serializes @odata.type, Name, and MDX. The TM1 REST API accepts additional properties on MDX views, most notably Meta, which enables powerful PAW/Planning Analytics Workspace features such as:

  • Meta.Aliases — display members using a specific alias instead of the element name
  • Meta.ContextSets — define subsets or expressions for context (title/WHERE) dimensions
  • Meta.ExpandAboves — control expand-above behaviour per dimension

Without access to these properties from TM1py, these settings can only be configured interactively inside PAW and cannot be managed programmatically or via automation pipelines.

Proposed Change

Add an optional properties: dict parameter to MDXView.__init__() and include it in construct_body():

def __init__(self, cube_name: str, view_name: str, MDX: str, properties: Optional[Dict] = None):
    ...
    self._properties = properties or {}

def construct_body(self) -> str:
    mdx_view_as_dict = collections.OrderedDict()
    mdx_view_as_dict["@odata.type"] = "ibm.tm1.api.v1.MDXView"
    mdx_view_as_dict["Name"] = self._name
    mdx_view_as_dict["MDX"] = self._mdx
    mdx_view_as_dict.update(self._properties)
    return json.dumps(mdx_view_as_dict, ensure_ascii=False)

Example Usage

view = MDXView(
    cube_name="EIS_CUBE",
    view_name="Dummy_View",
    MDX="SELECT ... FROM [EIS_CUBE] WHERE (...)",
    properties={
        "IsAutocalculate": False,
        "Meta": {
            "Aliases": {"[dim_One].[dim_One]": "Short_DE"},
            "ContextSets": {
                "[dim_Four].[dim_Four]": {"IsPublic": True, "SubsetName": "Default"},
                "[dim_Three].[dim_Three]": {"Expression": "{[dim_Three].[dim_Three].MEMBERS}"}
            },
            "ExpandAboves": {
                "[dim_Four].[dim_Four]": False,
                "[dim_Two].[dim_Two]": False
            }
        }
    }
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions