skillfed

mdxpy

A simple, yet elegant MDX library for TM1

mdxpy v1.3.2 291.8K downloads/30d#7,969 on PyPI36
Permissive license MIT-LICENSE Active released

What it is and what it does

MDXpy is a Python library for constructing MDX (Multidimensional Expressions) queries used by IBM Cognos TM1 and Planning Analytics. Instead of writing raw MDX strings, you use classes like Member, MdxTuple, MdxHierarchySet, and MdxBuilder to assemble queries programmatically. The library handles syntax details—bracket escaping, proper nesting, function formatting—so you focus on the query logic rather than MDX grammar.

The package supports a broad set of MDX functions including TM1SUBSETALL, FILTER, TOPCOUNT, UNION, and others, and allows chaining operations in a functional style. It handles multi-axis queries, calculated members, dimension properties, and zero suppression configuration. The main benefit is reducing syntax errors and making queries easier to refactor and maintain, especially for teams less familiar with MDX syntax.

Use it for:

  • Build dynamic TM1 queries in Python without manually escaping brackets or worrying about missing parentheses
  • Generate MDX queries for Planning Analytics reports where query structure varies based on user input or configuration
  • Construct multi-axis MDX queries with calculated members and dimension properties for complex reporting
  • Refactor existing raw MDX strings into maintainable, version-controlled Python code
  • Create reusable query templates by composing Member, MdxHierarchySet, and MdxBuilder objects

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Builds MDX queries programmatically for TM1 and IBM Cognos Planning Analytics, eliminating manual syntax errors and escaping concerns.

Yes, if you work with TM1 or IBM Cognos Planning Analytics and write MDX queries regularly. The library eliminates a common source of errors and makes queries more maintainable. The high install friction is a minor drawback, but the active maintenance status and zero security vulnerabilities support adoption. Not relevant for projects that do not use TM1 or Planning Analytics.

Install

mdxpy on PyPI

pip

pip install mdxpy

uv

uv add mdxpy

poetry

poetry add mdxpy

Installing mdxpy

Before you install

High install friction reported; package has no runtime dependencies but the distribution artifact suggests potential build or extraction complexity. Maintenance is active with recent commits.

License in practice

MIT license (permissive) allows commercial and private use with minimal restrictions—suitable for most projects.

Quickstart

from mdxpy import Member, MdxTuple, MdxBuilder

mdx_tuple = MdxTuple.of(Member.of("Product", "Product1"), Member.of("Region", "US"))
print(mdx_tuple.to_mdx())

query = MdxBuilder.from_cube("Cube").add_hierarchy_set_to_column_axis(
    MdxHierarchySet.all_leaves("Product")
).to_mdx()

Verify before relying

  • Whether high install friction stems from a compiled dependency or packaging issue not evident in the metadata
  • Whether the gap between latest release (2023-08-07) and current date indicates active maintenance or dormancy despite recent commits

Package facts

License MIT-LICENSE (permissive)
Python support supports the current Python release (>=3.5)
Install friction high — source build required
Runtime dependencies none
Maintenance actively maintained — 1,103 days since the last release
Last repo commit
First released
Downloads 291,849/month — #7,969 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: mdxpy-1.3.2.tar.gz

Keywords: MDX, TM1, IBM Cognos TM1, Planning Analytics, PA, Cognos

Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPython

Tags

MDX query builderTM1 query constructionIBM Cognos Planning AnalyticsMDX syntax generationprogrammatic MDXTM1 member queriesMDX set operations
mdx-query-buildertm1-cognosolap

More Database packages