mdxpy
A simple, yet elegant MDX library for TM1
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 mdxpyuv
uv add mdxpypoetry
poetry add mdxpyInstalling 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
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
TM1pyTM1py provides Python bindings to IBM Planning…
permissive · top 15,000 on PyPI
django-query-builderBuilds and executes complex SQL queries…
permissive · top 15,000 on PyPI
hf-doc-builderBuilds and previews documentation for Hugging…
permissive · top 15,000 on PyPI
outlinesOutlines constrains LLM generation to produce…
permissive · top 5,000 on PyPI
sqlalchemy-mixinsProvides Active Record-style mixins for…
permissive · top 15,000 on PyPI
luqumParses Lucene Query DSL syntax into an abstract…
unclear · top 5,000 on PyPI
apache-supersetApache Superset is a web-based business…
permissive · top 5,000 on PyPI
azure-mgmt-sqlProvides programmatic management of Azure SQL…
permissive · top 5,000 on PyPI
sqlalchemy-ibmiProvides a SQLAlchemy dialect to connect to Db2…
permissive · top 15,000 on PyPI
altexAltex wraps Altair to provide a simple,…
permissive · top 15,000 on PyPI