A simple, yet elegant MDX library for TM1

MDXpy enables Python developers to create MDX queries programmatically without hacking raw MDX queries.

Benefits

  • Faster to write
  • Requires less MDX knowledge
  • Detailed errors handling
  • Eliminates syntax errors (e.g. forget }, ], ) in a query) forever
  • Makes code more robust and easier to refactor
  • Handle common pit falls in MDX: (e.g. escape ‘]’ in names and make ‘instr’ method case insensitive)

The Member Class

The Member class is a core building block for the MdxTuple and the MdxHierarchySet classes. To create a Member, use the Member.of(*args: str) method:

The MdxTuple Class

The MdxTuple class is a static collection of Members. Create a MdxTuple with the static of(*args: Member) method. The MDX expression of the tuple is generated with the to_mdx method.

The MdxHierarchySet Class

The MdxHierarchySet class controls an MDX expression for a hierarchy. MdxHierarchySet is created with any of the static methods on the MdxHierarchySet class.

The MdxHierarchySet class controls an MDX expression for a hierarchy. MdxHierarchySet is created with any of the static methods on the MdxHierarchySet class.

The MdxBuilder Class

The MdxBuilder is used to build MDX queries. MdxHierarchySet or MdxTuple are placed on the axes. Zero suppression can be switched on or off per axis.

Supported MDX Functions:

TM1SUBSETALLMEMBERSTM1SUBSETTOSETDEFAULTMEMBERPARENTFIRSTCHILDLASTCHILDCHILDREN
ANCESTORSANCESTORDRILLDOWNLEVELFILTERTM1FILTERBYPATTERNTM1FILTERBYLEVELTM1SORTHEAD
TAILSUBSETTOPCOUNTBOTTOMCOUNTUNIONINTERSECTEXCEPTORDER

How to install it

MDXpy is available as a Python package. Once Python is installed, to install MDXpy, just open a command line and type pip install mdxpy